Re: [SQL] obtaining difference between minimum value and next in size

2010-11-17 Thread John Lister
groups. John - Original Message - From: Oliveiros d'Azevedo Cristina To: John Lister ; pgsql-sql@postgresql.org Sent: Wednesday, November 17, 2010 4:09 PM Subject: Re: [SQL] obtaining difference between minimum value and next in size Hi, John. I am not familiar wit

[SQL] obtaining difference between minimum value and next in size

2010-11-17 Thread John Lister
Hi, I was wondering if it is possible to do this with a single query rather than iterate over all of the rows in an application: I have a table which for brevity looks like: create table offers { integer id; integer product_id; double price; } where for each product there is a number of of

[SQL] Partitioning improvements query

2010-02-04 Thread John Lister
Hi all, I was just wondering if any progress has been made on improving partitioning, particuarly performance wise. I've found a few documents on the web, for example: http://wiki.postgresql.org/wiki/Table_partitioning and http://wiki.postgresql.org/wiki/Image:Partitioning_Requirements.pdf, ht

Re: [SQL] Partitioning by letter question

2010-01-30 Thread John Lister
wrote: Hi, I was wondering if this was possible. I'm trying to partition a table, which is straightforward enough thanks to the great documentation, but i have a question: If I partition using something like a product_id for example and have check constraints such as (id>=1000 and id<2000) t

[SQL] Partitioning by letter question

2010-01-29 Thread John Lister
Hi, I was wondering if this was possible. I'm trying to partition a table, which is straightforward enough thanks to the great documentation, but i have a question: If I partition using something like a product_id for example and have check constraints such as (id>=1000 and id<2000) then every

Re: [SQL] Query planning question

2009-05-11 Thread John Lister
"John Lister" writes: Am I right in assuming the planner thinks a sequential scan is quicker than 10k index hits, would tweaking the costs fix this or would i be better updating the stats for the product_id and manufacturer_id fields? AFAICT the planner did exactly the right t

[SQL] Query planning question

2009-05-11 Thread John Lister
Doing the following query select distinct m.id, m.name from manufacturer_manufacturer m join product_product p on (p.manufacturer_id=m.id) join retailer_offer o on (o.product_id=p.id) where o.retailer_id=XXX and o.active results in one of 2 query plans depending upon the v

[SQL] temp tables versus normal tables

2009-02-16 Thread John Lister
I've got a process that every minute or so selects some data from a number of tables. At the minute i dump this into a normal table, where i do some more processing with it before truncating the table and starting again.. I don't have any indexes on the temporary table but have thought about add

Re: [SQL] Best way to "and" from a one-to-many joined table?

2008-12-08 Thread John Lister
I guess it depends on the optimiser and how clever it is. With the former the db will probably generate 2 sets of ids for the 2 joined tables (a, b) which only contain the values you require, these lists are probably much smaller than the total number of rows in the table therefore any merges a

Re: [SQL] adding "order by" to a "group by" query

2008-12-06 Thread John Lister
>(still curious about the "must be used in an aggregate function" error >though... because I do use it in an aggregate) You're original query grouped on the person id and name, therefore you can only return (and order by) these functions or the result of an aggregate function on other columns

Re: [SQL] Full text search ordering question

2008-11-25 Thread John Lister
g version is also useful. Did you try GIN index ? In 8.4 you can use gin index on (views,tsvector) Oleg On Tue, 25 Nov 2008, John Lister wrote: Hi, is it possible to order the results of a full text search using another field? for example with the following table: CREATE TABLE breadcrumb

[SQL] Full text search ordering question

2008-11-25 Thread John Lister
Hi, is it possible to order the results of a full text search using another field? for example with the following table: CREATE TABLE breadcrumbs ( node_id integer NOT NULL, breadcrumb character varying, textsearchable tsvector, views integer, CONSTRAINT pk_breadcrumbs PRIMARY KEY (node_id