Re: [GENERAL] Suboptimal query plan fixed by replacing OR with UNION

2012-07-06 Thread Gurjeet Singh
On Thu, Jul 5, 2012 at 7:16 PM, Steven Schlansker wrote: > > On Jul 5, 2012, at 3:51 PM, Tom Lane wrote: > > > Steven Schlansker writes: > >> Why is using an OR so awful here? > > > > Because the OR stops it from being a join (it possibly needs to return > > some rows that are not in the semijoin

Re: [GENERAL] two-column primary key (not the typical question)

2012-07-06 Thread Gurjeet Singh
On Fri, Jul 6, 2012 at 10:00 PM, Chip Nowacek wrote: > I need a suggestion. I need a two-column primary key that does not depend > on the order of the entries. That is, for the purposes of the key: > > PKColA PKColB > foobar > barfoo > > is not valid. > I don't think

Re: [GENERAL] two-column primary key (not the typical question)

2012-07-06 Thread Chris Travers
On Fri, Jul 6, 2012 at 7:00 PM, Chip Nowacek wrote: > I need a suggestion. I need a two-column primary key that does not depend > on the order of the entries. That is, for the purposes of the key: > > PKColA PKColB > foobar > barfoo > What about a unique functional in

[GENERAL] two-column primary key (not the typical question)

2012-07-06 Thread Chip Nowacek
I need a suggestion. I need a two-column primary key that does not depend on the order of the entries. That is, for the purposes of the key: PKColA PKColB foobar barfoo is not valid. Any help would be appreciated.

Re: [GENERAL] Re: index and data tablespaces on two separate drives or one RAID 0?

2012-07-06 Thread John R Pierce
On 07/06/12 5:51 PM, ach wrote: My fastest postgresql servers have everything on one raid10, using 16 or >20 15000 rpm SAS2 drives on a 1gb flash-backed cache controller. Thank you - that affirms what'd been my own growing supposition, and the plan >why? Really? ...Well, I mean, I'd just bee

Re: [GENERAL] Help with sql

2012-07-06 Thread Steve Crawford
On 07/06/2012 02:34 PM, Perry Smith wrote: Hi Guys, This isn't a PostgreSQL specific question but just a SQL question. If this is not an appropriate question for this list, please let me know. It is also, perhaps, a really silly question. This query (without the 'explain' keyword) , when exe

[GENERAL] Re: index and data tablespaces on two separate drives or one RAID 0?

2012-07-06 Thread ach
> My fastest postgresql servers have everything on one raid10, using 16 or > 20 15000 rpm SAS2 drives on a 1gb flash-backed cache controller. Thank you - that affirms what'd been my own growing supposition, and the plan > why? Really? ...Well, I mean, I'd just been going with what I'd seen as

Re: [GENERAL] Help with sql

2012-07-06 Thread Rob Sargent
On 07/06/2012 03:34 PM, Perry Smith wrote: Hi Guys, This isn't a PostgreSQL specific question but just a SQL question. If this is not an appropriate question for this list, please let me know. It is also, perhaps, a really silly question. This query (without the 'explain' keyword) , when exe

[GENERAL] Help with sql

2012-07-06 Thread Perry Smith
Hi Guys, This isn't a PostgreSQL specific question but just a SQL question. If this is not an appropriate question for this list, please let me know. It is also, perhaps, a really silly question. This query (without the 'explain' keyword) , when executed takes forever and a day: > condor_dev

Re: [GENERAL] Suboptimal query plan fixed by replacing OR with UNION

2012-07-06 Thread Steven Schlansker
On Jul 5, 2012, at 6:35 PM, Jasen Betts wrote: > I note you've decided to rewrite this query as a union > >> SELECT * FROM account >> WHERE user_id in >>(SELECT user_id FROM account >> WHERE id = >> ANY('{-02f6-379d-c000-00026810,-0320-b467-c000-00026810,000

Re: [GENERAL] Weird "LIKE" behaviour

2012-07-06 Thread David Johnston
> -Original Message- > From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] On Behalf Of Andy Chambers > Sent: Friday, July 06, 2012 4:34 PM > To: pgsql > Subject: Re: [GENERAL] Weird "LIKE" behaviour > > On Fri, Jul 6, 2012 at 4:26 PM, David Johnston wr

Re: [GENERAL] Weird "LIKE" behaviour

2012-07-06 Thread Andy Chambers
On Fri, Jul 6, 2012 at 4:26 PM, David Johnston wrote: >> -Original Message- >> From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- >> ow...@postgresql.org] On Behalf Of Andy Chambers >> Sent: Friday, July 06, 2012 4:17 PM >> To: pgsql >> Subject: [GENERAL] Weird "LIKE" behaviou

Re: [GENERAL] Weird "LIKE" behaviour

2012-07-06 Thread David Johnston
> -Original Message- > From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] On Behalf Of Andy Chambers > Sent: Friday, July 06, 2012 4:17 PM > To: pgsql > Subject: [GENERAL] Weird "LIKE" behaviour > > Below are two queries that should be pretty much the s

[GENERAL] Weird "LIKE" behaviour

2012-07-06 Thread Andy Chambers
Below are two queries that should be pretty much the same but with the first one, I'm trying to boil it down to a minimal test-case so I don't have to export the table definition of dcm.providers. The first one returns nothing but at least executes the query. => create table foo ( foo text ); =>

Re: [GENERAL] Primary key vs unique index

2012-07-06 Thread Gurjeet Singh
On Fri, Jul 6, 2012 at 2:07 PM, rverghese wrote: > Yes I am using that option for one of my POstgres 9.1 database and it works > well. But its still an issue with Foreign keys, which you need to drop and > recreate . Having to drop and create foriegn keys is a legitimate concern. I am looking i

[GENERAL] Tutorial On Connecting LibreOffice to PostgreSQL Available

2012-07-06 Thread Don Parris
Hi all, I believe this may be pertinent here. Last year I wrote a tutorial on connecting LibreOffice to the powerful PostgreSQL database server. Now there is an updated driver that allows read-write access. So I've updated my tutorial, complete with screenshots this time. The actual connection s

[GENERAL] Query runtime strongly dependent on generated statistics (and fewer statistics are better?)

2012-07-06 Thread Viktor Rosenfeld
Hi, (I've sent this mail about month ago, but received no reply. So I'm trying again.) I've noticed that the selection of the executed query plan (and therefore query runtime) is dependent on the statistics generated by an ANALYZE run. As an demonstration, I chose the best runtime of 5 consecutiv

[GENERAL] BUG? Regular expression matching of optional character group at beginning of RE

2012-07-06 Thread Viktor Rosenfeld
Hi, I've noticed that regular expressions which are anchored at the beginning of the text but have an optional part at the beginning (e.g. '^(ge)?kommen$') are not evaluated correctly if there is an index on the column. Consider the following table: #+BEGIN_SRC sql CREATE TABLE annotation (

Re: [GENERAL] index and data tablespaces on two separate drives or one RAID 0?

2012-07-06 Thread John R Pierce
On 07/06/12 10:05 AM, ach wrote: A) Leave the disk setup as-is, with indexes on one drive and tables on another? OR B) Combine the two separate drives into a single RAID 0, put both indexes and table data on that RAID, and run from there? My fastest postgresql servers have everything on

Re: [GENERAL] Primary key vs unique index

2012-07-06 Thread rverghese
Yes I am using that option for one of my POstgres 9.1 database and it works well. But its still an issue with Foreign keys, which you need to drop and recreate . Also I use Slony for replication and it uses the primary key to check repl. So I don't want that to be interrupted by dropping PK and rec

Re: [GENERAL] Primary key vs unique index

2012-07-06 Thread Gurjeet Singh
Bloat in primary key indexes has been a long standing issue (although not faced by many), and especially since online rebuild of primary keys was never possible in production environments. Since version 9.1 we have a nice little feature of being able to change a primary key's underlying index. Loo

[GENERAL] index and data tablespaces on two separate drives or one RAID 0?

2012-07-06 Thread ach
First and foremost, I just want to say Thank You, very much, sincerely, to the entire PostgreSQL community for everything you are, do and have built. Without going into an exorbitant amount of detail, suffice it to say that in the context of my current work, you have truly been a Godsend. I have

Re: [GENERAL] Primary key vs unique index

2012-07-06 Thread hubert depesz lubaczewski
On Fri, Jul 06, 2012 at 09:07:53AM -0700, rverghese wrote: > We are experiencing a similar problem, even though we are on 8.4 and have > been for a while, and have autovacuum turned on. I have regular concurrent > reindexes on the indexes but the primary key is seriously bloated. I was > considerin

Re: [GENERAL] Dynamic query execution using array

2012-07-06 Thread Pavel Stehule
2012/7/6 Pavel Stehule : > 2012/7/6 ChoonSoo Park : >> It works! >> >> One more question. >> Do I have to use CAST for parameter value holder? > you can cast array to int array string_to_array(..., ',')::int[] Regards Pavel > probably > > all values in array should to share one type, and when

Re: [GENERAL] Dynamic query execution using array

2012-07-06 Thread Pavel Stehule
2012/7/6 ChoonSoo Park : > It works! > > One more question. > Do I have to use CAST for parameter value holder? probably all values in array should to share one type, and when this type is not same like holder, then you need cast Regards Pavel > > employee table's dept_id and salary columns ar

Re: [GENERAL] Dynamic query execution using array

2012-07-06 Thread ChoonSoo Park
It works! One more question. Do I have to use CAST for parameter value holder? employee table's dept_id and salary columns are integer types. RETURN QUERY EXECUTE 'SELECT * FROM employee WHERE dept_id = $1[1] and salary <= $1[2]' using tmpArrayValues; When I use text array, it complains: ERROR:

Re: [GENERAL] Primary key vs unique index

2012-07-06 Thread rverghese
We are experiencing a similar problem, even though we are on 8.4 and have been for a while, and have autovacuum turned on. I have regular concurrent reindexes on the indexes but the primary key is seriously bloated. I was considering doing the same thing, that is, create another primary key that is

Re: [GENERAL] Dynamic query execution using array

2012-07-06 Thread Pavel Stehule
Hello 2012/7/6 ChoonSoo Park : > Inside a function, I can execute dynamic query like this > > dept_id = 1; > salary = 5; > RETURN QUERY EXECUTE 'SELECT * FROM employee WHERE dept_id = $1 and > salary >= $2' using dept_id, salary; > > When the query condition is dynamically ge

[GENERAL] Dynamic query execution using array

2012-07-06 Thread ChoonSoo Park
Inside a function, I can execute dynamic query like this dept_id = 1; salary = 5; RETURN QUERY EXECUTE 'SELECT * FROM employee WHERE dept_id = $1 and salary >= $2' using dept_id, salary; When the query condition is dynamically generated and number of parameters is also dynam

Re: [GENERAL] Draw Model from existing DB

2012-07-06 Thread Robert Gravsjö
> I have an existing PostgreSQL DB and I would like to draw a model of the DB > structure. Is there some software (Freeware) around that can read the > existing structure of my DB and automatically draw e.g. an ER-model of that? > The software that I have found so far (e.g. Open System Architect) s