[SQL] selecting latest record

2009-09-22 Thread Louis-David Mitterrand
Hi, I have a simple table price(id_product, price, date) which records price changes for each id_product. Each time a price changes a new tuple is created. What is the best way to select only the latest price of each id_product? Thanks, -- Sent via pgsql-sql mailing list

Re: [SQL] selecting latest record

2009-09-22 Thread Pavel Stehule
Hello 2009/9/22 Louis-David Mitterrand vindex+lists-pgsql-...@apartia.org: Hi, I have a simple table price(id_product, price, date) which records price changes for each id_product. Each time a price changes a new tuple is created. What is the best way to select only the latest price of

Re: [SQL] selecting latest record

2009-09-22 Thread Louis-David Mitterrand
On Tue, Sep 22, 2009 at 11:56:54AM +0200, Pavel Stehule wrote: there are more ways - depends on what you wont. one way is SELECT * FROM price WHERE (id_product, date) = (SELECT id_product, max(date) FROM price

Re: [SQL] selecting latest record

2009-09-22 Thread A. Kretschmer
In response to Louis-David Mitterrand : Hi, I have a simple table price(id_product, price, date) which records price changes for each id_product. Each time a price changes a new tuple is created. What is the best way to select only the latest price of each id_product? There are

Re: [SQL] selecting latest record

2009-09-22 Thread Rob Sargent
Let's say there's an index on the date column: Does the where clause approach necessarily out perform the distinct on version? Hoping the OP has enough data to make analyse useful. A. Kretschmer wrote: In response to Louis-David Mitterrand : Hi, I have a simple table price(id_product,

[SQL] AccessExclusiveLock on CREATE TABLE REFERENCES deadlocks (formatted better)

2009-09-22 Thread Bryce Nesbitt
Dear Postgres Gurus; I've just diagnosed a PostgreSQL 8.3.4 server which, about once a month, would deadlock shortly after 11pm. It had been doing this for years, and the prior response was simply to reboot everything. The culprit boils down to: # create table cache_table_20090921 ( site_key

[SQL] AccessExclusiveLock on CREATE TABLE REFERENCES deadlocks

2009-09-22 Thread Bryce Nesbitt
Dear Postgres Gurus; I've just diagnosed a PostgreSQL 8.3.4 server which, about once a month, would deadlock shortly after 11pm. It had been doing this for years, and the prior response was simply to reboot everything. The culprit boils down to: # create table cache_table_20090921 ( site_key

Re: [SQL] AccessExclusiveLock on CREATE TABLE REFERENCES deadlocks (formatted better)

2009-09-22 Thread Tom Lane
Bryce Nesbitt bry...@obviously.com writes: 1) Why the AccessExclusiveLock on create table? It has to install a trigger on the referenced table. There has been some discussion that maybe CREATE TRIGGER could take just ExclusiveLock and not AccessExclusiveLock, but it hasn't been done yet; and

Re: [SQL] AccessExclusiveLock on CREATE TABLE REFERENCES deadlocks (formatted better)

2009-09-22 Thread Bryce Nesbitt
Tom Lane wrote: Bryce Nesbitt bry...@obviously.com writes: 1) Why the AccessExclusiveLock on create table? It has to install a trigger on the referenced table. There has been some discussion that maybe CREATE TRIGGER could take just ExclusiveLock and not

[SQL] Data integration tool in Chinese?

2009-09-22 Thread hfdabler
Hello to all, Being in a pretty much international company, I have come here to ask a few things about ETL tools and their different languages. We have offices in the US, in Europe (Italy, France) and in China. We think English is fine but our European team and Chinese team especially would

Re: [SQL] Data integration tool in Chinese?

2009-09-22 Thread Rob Sargent
Are you asking that all strings be stored into the other three languages as part of (potentially many-master) replication? hfdabler wrote: Hello to all, Being in a pretty much international company, I have come here to ask a few things about ETL tools and their different languages. We