Re: [GENERAL] Query organization question

2009-04-28 Thread Sam Mason
On Mon, Apr 27, 2009 at 02:15:05PM -0700, Gauthier, Dave wrote: > The stored procedure calls another recursive stored procedure that > can take a long time to run, usually about 3-4 seconds. Not bad for > a handful of records, but it is now operating on a table with over > 40,000 records. The mos

Re: [GENERAL] Query organization question

2009-04-27 Thread Gauthier, Dave
ssage- From: Grzegorz Jaśkiewicz [mailto:gryz...@gmail.com] Sent: Monday, April 27, 2009 5:04 PM To: Gauthier, Dave Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Query organization question >   exists (select 'found_it' from get_jobs(x.name) j where j.job = > 'carpente

Re: [GENERAL] Query organization question

2009-04-27 Thread Grzegorz Jaśkiewicz
>   exists (select ‘found_it’ from get_jobs(x.name) j where j.job = > ‘carpenter’); What does this function do ? If it only runs on the tables, than simple join will do it pretty fast. also, keeping job as integer, if table is large will save you some space, make index lookup faster, and generally

[GENERAL] Query organization question

2009-04-27 Thread Gauthier, Dave
I have a poorly performing query that looks something like select x.name, x.title, x.value from (select a.name as name, b.book_title as title, c.cost as value from ..) x where exists (select 'found_it' from get_jobs(x.name) j where j.job = 'carpenter'); I did it this way because I was