[PERFORM] EXPLAIN detail

2008-04-09 Thread Luigi N. Puleio
Hello everyone!! I have a table with 17 columns and it has almost 53 records and doing just a SELECT * FROM table with the EXPLAIN ANALYZE I get: Seq Scan on table (cost=0.00...19452.95 rows=529395 width=170) (actual time=0.155...2194.294 rows=529395 loops=1) total runtime=3679.039 ms

Re: [PERFORM] EXPLAIN detail

2008-04-09 Thread Craig Ringer
Luigi N. Puleio wrote: SELECT (a.column1)::date, MIN(b.column2) - a.column2 FROM table a inner join table b on ((a.column1)::date = (b.column1)::date amd b.column3 = 'b' and (b.column1)::time without time zone = (a.column1)::time without time zone) WHERE

Re: [PERFORM] EXPLAIN detail

2008-04-09 Thread Pavan Deolasee
On Wed, Apr 9, 2008 at 3:21 PM, Luigi N. Puleio [EMAIL PROTECTED] wrote: Hello everyone!! I have a table with 17 columns and it has almost 53 records and doing just a SELECT * FROM table with the EXPLAIN ANALYZE I get: Seq Scan on table (cost=0.00...19452.95 rows=529395

Re: [PERFORM] EXPLAIN detail

2008-04-09 Thread Matthew
On Wed, 9 Apr 2008, Pavan Deolasee wrote: I have a table with 17 columns and it has almost 53 records and doing just a SELECT * FROM table Well, PK won't help you here because you are selecting all rows from the table and that seq scan is the right thing for that. Yes. Like he said.

Re: [PERFORM] EXPLAIN detail

2008-04-09 Thread Luigi N. Puleio
SELECT (a.column1)::date, MIN(b.column2) - a.column2 FROM table a inner join table b on ((a.column1)::date = (b.column1)::date amd b.column3 = 'b' and (b.column1)::time without time zone = (a.column1)::time without time zone) WHERE (a.column1)::date =

Re: [PERFORM] EXPLAIN detail

2008-04-09 Thread Craig Ringer
Luigi N. Puleio wrote: With all that casting, is it possible that appropriate indexes aren't being used because your WHERE / ON clauses aren't an exact type match for the index? You mean to put an index on date with timestamptz datatype column?... Er ... I'm not quite sure what you mean.

Re: [PERFORM] EXPLAIN detail

2008-04-09 Thread Luigi N. Puleio
With all that casting, is it possible that appropriate indexes aren't being used because your WHERE / ON clauses aren't an exact type match for the index? You mean to put an index on date with timestamptz datatype column?... Er ... I'm not quite sure what you mean. Do you mean an index on

Re: [PERFORM] EXPLAIN detail

2008-04-09 Thread Craig Ringer
Luigi N. Puleio wrote: If for some reason you cannot do that, please at least include the data type of the primary key and all fields involved in the query, as well as a list of all the indexes on both tables. If you won't show people on the list your table definitions, or at least the

Re: [PERFORM] EXPLAIN detail

2008-04-09 Thread PFC
Well, this table has a primary key index on first column called acctid which is an integer; instead the calldate column is a TIMESTAMPTZ and in fact I'm using to do (calldate)::date in the ON clause because since the time part of that column is always different and in the nesting I have

Re: [PERFORM] EXPLAIN detail

2008-04-09 Thread Richard Broersma
On Wed, Apr 9, 2008 at 11:41 AM, PFC [EMAIL PROTECTED] wrote: In order to use the index, you could rewrite it as something like : a.calldate = '2008-04-09' AND a.calldate ('2008-04-09'::DATE + '1 DAY'::INTERVAL) This is a RANGE query (just like BETWEEN) which is