Re: [SQL] cost of CREATE VIEW ... AS SELECT DISTINCT

2005-03-29 Thread T E Schmitz
Bruno Wolff III wrote: On Tue, Mar 29, 2005 at 14:21:15 +0100, T E Schmitz <[EMAIL PROTECTED]> wrote: If that's the case, I should come up with a different concept to obtain a list of ORIGINs. That may be a good idea, especially if there are lots of rows for each origin value. That's what I wi

Re: [SQL] cost of CREATE VIEW ... AS SELECT DISTINCT

2005-03-29 Thread Tom Lane
T E Schmitz <[EMAIL PROTECTED]> writes: > As far as I can see (via EXPLAIN), both DISTINCT and GROUP BY will lead > to a sequentail scan. Is that correct? I'm not sure why you expect something different. The query requires visiting every row of the table in any case --- else it might miss values

Re: [SQL] cost of CREATE VIEW ... AS SELECT DISTINCT

2005-03-29 Thread Bruno Wolff III
On Tue, Mar 29, 2005 at 15:12:24 +0100, T E Schmitz <[EMAIL PROTECTED]> wrote: > > Shall do. > But am I correct in assuming that I should place an index on the group > by (TRANSAKTION.ORIGIN) column? This will mainly help when joining the view to another table. This would also allow using an i

Re: [SQL] cost of CREATE VIEW ... AS SELECT DISTINCT

2005-03-29 Thread Bruno Wolff III
On Tue, Mar 29, 2005 at 14:21:15 +0100, T E Schmitz <[EMAIL PROTECTED]> wrote: > > As far as I can see (via EXPLAIN), both DISTINCT and GROUP BY will lead > to a sequentail scan. Is that correct? If you need to read the whole table yes. However if you join the view to something else that might

Re: [SQL] cost of CREATE VIEW ... AS SELECT DISTINCT

2005-03-29 Thread T E Schmitz
Alvaro Herrera wrote: On Tue, Mar 29, 2005 at 02:21:15PM +0100, T E Schmitz wrote: Bruno Wolff III wrote: On Tue, Mar 29, 2005 at 11:07:20 +0100, T E Schmitz <[EMAIL PROTECTED]> wrote: Would the "SELECT DISTINCT origin" always cause a sequential table scan regardless whether there is an index on t

Re: [SQL] cost of CREATE VIEW ... AS SELECT DISTINCT

2005-03-29 Thread Alvaro Herrera
On Tue, Mar 29, 2005 at 02:21:15PM +0100, T E Schmitz wrote: > Bruno Wolff III wrote: > >On Tue, Mar 29, 2005 at 11:07:20 +0100, > > T E Schmitz <[EMAIL PROTECTED]> wrote: > > > >>Would the "SELECT DISTINCT origin" always cause a sequential table > >>scan regardless whether there is an index on th

Re: [SQL] cost of CREATE VIEW ... AS SELECT DISTINCT

2005-03-29 Thread T E Schmitz
Bruno Wolff III wrote: On Tue, Mar 29, 2005 at 11:07:20 +0100, T E Schmitz <[EMAIL PROTECTED]> wrote: Would the "SELECT DISTINCT origin" always cause a sequential table scan regardless whether there is an index on the origin column or not? It's worse than that, SELECT DISTINCT cannot use a hash

Re: [SQL] cost of CREATE VIEW ... AS SELECT DISTINCT

2005-03-29 Thread Bruno Wolff III
On Tue, Mar 29, 2005 at 11:07:20 +0100, T E Schmitz <[EMAIL PROTECTED]> wrote: > > Would the "SELECT DISTINCT origin" always cause a sequential table scan > regardless whether there is an index on the origin column or not? It's worse than that, SELECT DISTINCT cannot use a hash aggregate plan

Re: [SQL] cost of CREATE VIEW ... AS SELECT DISTINCT

2005-03-29 Thread Sean Davis
On Mar 29, 2005, at 5:07 AM, T E Schmitz wrote: Hello Scott, Scott Marlowe wrote: On Mon, 2005-03-28 at 15:43, T E Schmitz wrote: How expensive would it be to maintain the following VIEW: CREATE VIEW origin AS SELECT DISTINCT origin FROM transaktion if there is in index on transaktion.origin; the t

Re: [SQL] cost of CREATE VIEW ... AS SELECT DISTINCT

2005-03-29 Thread T E Schmitz
Hello Scott, Scott Marlowe wrote: On Mon, 2005-03-28 at 15:43, T E Schmitz wrote: How expensive would it be to maintain the following VIEW: CREATE VIEW origin AS SELECT DISTINCT origin FROM transaktion if there is in index on transaktion.origin; the table transaktion has thousands of records and t

Re: [SQL] cost of CREATE VIEW ... AS SELECT DISTINCT

2005-03-28 Thread Scott Marlowe
On Mon, 2005-03-28 at 15:43, T E Schmitz wrote: > Hello, > How expensive would it be to maintain the following VIEW: > > CREATE VIEW origin AS SELECT DISTINCT origin FROM transaktion > > if there is in index on transaktion.origin; the table transaktion has > thousands of records and there are on

[SQL] cost of CREATE VIEW ... AS SELECT DISTINCT

2005-03-28 Thread T E Schmitz
Hello, How expensive would it be to maintain the following VIEW: CREATE VIEW origin AS SELECT DISTINCT origin FROM transaktion if there is in index on transaktion.origin; the table transaktion has thousands of records and there are only a few distinct origin? -- Regards/Gruß, Tarlika Elisabeth Sc