Re: [GENERAL] SQL WHERE: many sql or large IN()

2007-04-20 Thread Chris
tom wrote: This is some good stuff and I can use the explain analyze going forward. But I can't get these VALUES queries to work. I checked and I am on version 8.1. but I think from the docs that I should still be able to do this. Multiple VALUES was introduced in 8.2 as others mentioned so

Re: [GENERAL] SQL WHERE: many sql or large IN()

2007-04-06 Thread tom
This is some good stuff and I can use the explain analyze going forward. But I can't get these VALUES queries to work. I checked and I am on version 8.1. but I think from the docs that I should still be able to do this. queue=> select t.* from test t, (values(4, 23,84884,1,324234)) as v wh

Re: [GENERAL] SQL WHERE: many sql or large IN()

2007-04-06 Thread Tom Lane
tom <[EMAIL PROTECTED]> writes: > I've never seen this before. > Is this PG specific or generic SQL that I've never been exposed to? It's in the SQL standard. SQL92 saith ::= VALUES ::= [ { }... ] and lists this as an alternative to (ie, a S

Re: [GENERAL] SQL WHERE: many sql or large IN()

2007-04-06 Thread Listmail
I've never seen this before. Is this PG specific or generic SQL that I've never been exposed to? http://www.postgresql.org/docs/8.2/interactive/sql-values.html VALUES conforms to the SQL standard, except that LIMIT and OFFSET are PostgreSQL extensions. It doesn't seem like much a

Re: [GENERAL] SQL WHERE: many sql or large IN()

2007-04-06 Thread tom
I've never seen this before. Is this PG specific or generic SQL that I've never been exposed to? On Apr 6, 2007, at 10:08 AM, Listmail wrote: I have a choice of running: SELECT bar FROM tokens WHERE foo IN ('apple','orange','biscuit') for up to ~300 words OR SELECT bar FROM tokens

Re: [GENERAL] SQL WHERE: many sql or large IN()

2007-04-06 Thread Listmail
On Fri, 06 Apr 2007 18:45:15 +0200, Markus Schiltknecht <[EMAIL PROTECTED]> wrote: Hi, tom wrote: Initially it seems that the WHERE IN (...) approach takes a turn for the worse when the list gets very large. Since I use this a lot on webpages, I thought maybe a little benchmark is in

Re: [GENERAL] SQL WHERE: many sql or large IN()

2007-04-06 Thread Markus Schiltknecht
Hi, tom wrote: Initially it seems that the WHERE IN (...) approach takes a turn for the worse when the list gets very large. What version do you use? PostgreSQL 8.2 had great improvements for that specific issue. Did you try EXPLAIN? Regards Markus ---(end of broa

Re: [GENERAL] SQL WHERE: many sql or large IN()

2007-04-06 Thread Listmail
I have a choice of running: SELECT bar FROM tokens WHERE foo IN ('apple','orange','biscuit') for up to ~300 words OR SELECT bar FROM tokens WHERE foo = 'apple' up to ~300 times as a prepared/cached SQL statements. With new PG versions you can also use VALUES which will save you a

Re: [GENERAL] SQL WHERE: many sql or large IN()

2007-04-06 Thread Oleg Bartunov
Aha, then why not use gin index for text[] ? see, for example, my testing http://www.sai.msu.su/~megera/wiki/GinTest oleg On Fri, 6 Apr 2007, tom wrote: If I read this right, intarray is for reading values from an array data type. I don't have this. I have a varchar() field that is indexed

Re: [GENERAL] SQL WHERE: many sql or large IN()

2007-04-06 Thread tom
If I read this right, intarray is for reading values from an array data type. I don't have this. I have a varchar() field that is indexed (unique), call it 'foo' I have a choice of running: SELECT bar FROM tokens WHERE foo IN ('apple','orange','biscuit') for up to ~300 words OR SELE

Re: [GENERAL] SQL WHERE: many sql or large IN()

2007-04-06 Thread Oleg Bartunov
Tom, have you seen contrib/intarray ? Oleg On Fri, 6 Apr 2007, tom wrote: I'm wondering where the differences are in running two different types of SQL statements. Given ~300 tokens/words I can either run 1 sql statement with a large list in a "WHERE foo IN (...300 tokens...)" or I can run

[GENERAL] SQL WHERE: many sql or large IN()

2007-04-06 Thread tom
I'm wondering where the differences are in running two different types of SQL statements. Given ~300 tokens/words I can either run 1 sql statement with a large list in a "WHERE foo IN (...300 tokens...)" or I can run ~300 statements, one for each token. In the first case, the SQL is not prep