Re: [PERFORM] Avoiding cartesian product

2006-02-19 Thread Virag Saksena
 Szűcs,     Thanks for your suggestion, I guess there is more than one way to attack the problem.   I ended up using a trick with limit to get the next row ...   select (b.gc_minor- a.gc_minor), (b.gc_major- a.gc_major)from jam_trace_sys a join jam_trace_sys b on(b.seq_no = (select c.seq_no

Re: [PERFORM] Need pointers to "standard" pg database(s) for

2006-02-19 Thread Christopher Kings-Lynne
Relating to this. If anyone can find govt or other free db's and convert them into pgsql format, I will host them on the dbsamples page. The dbsamples are _really_ popular! Chris Scott Marlowe wrote: On Fri, 2006-02-17 at 10:51, Ron wrote: I assume we have such? Depends on what you wanna

[PERFORM] How to optimize a JOIN with BETWEEN?

2006-02-19 Thread andrew
Here's a simplified version of the schema: Table A has an ID field, an observation date, and other stuff. There are about 20K IDs and 3K observations per ID. Table B has a matching ID field, minimum and maximum dates, a code, and other stuff, about 0-50 records per ID. For a given ID, the dates

Re: [PERFORM] Need pointers to "standard" pg database(s) for testing

2006-02-19 Thread Christopher Kings-Lynne
Not really, but you can check out the sample databases project: http://pgfoundry.org/projects/dbsamples/ Chris Ron wrote: I assume we have such? Ron ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [PERFORM] Question about query planner

2006-02-19 Thread Tom Lane
Emil Briggs <[EMAIL PROTECTED]> writes: > Does any know why the query behaves like this? Does it have anything to > do with the OR statements in the where clause spanning two different tables? Exactly. > SELECT DISTINCT a.account_id, l.username, a.status, a.company, a.fax_num, > a.primary_phone

Re: [PERFORM] Force another plan.

2006-02-19 Thread Tom Lane
Fredrik Olsson <[EMAIL PROTECTED]> writes: > -> Seq Scan on t_entities (cost=0.00..1.49 rows=7 width=4) > (actual time=404.539..409.302 rows=2 loops=1) > Filter: ((haveaccess(createdby, responsible, "class", > false) OR CASE WHEN (partof = 'contacts'::name) THEN > ischildof(

[PERFORM] Question about query planner

2006-02-19 Thread Emil Briggs
The following query runs much slower than I would have expected. I ran it through EXPLAIN ANALYZE (results included after) and I don't understand why the planner is doing what it is. All of the columns from the WHERE part of the query are indexed and the indexes are being used. The number of r

Re: [PERFORM] Force another plan.

2006-02-19 Thread Fredrik Olsson
Tom Lane skrev: Fredrik Olsson <[EMAIL PROTECTED]> writes: I have some quite huge queries, inside functions, so debugging is kind of hard. But I have located the query that for some reason gets 4 times as slow after an analyze. Could we see EXPLAIN ANALYZE output for these cases, not