Re: How slow is DISTINCT?
От | Wei Weng |
---|---|
Тема | Re: How slow is DISTINCT? |
Дата | |
Msg-id | 3C7D69B6.4070301@kencast.com обсуждение исходный текст |
Ответ на | Re: How slow is DISTINCT? ("Josh Berkus" <josh@agliodbs.com>) |
Список | pgsql-sql |
Josh Berkus wrote: > Wei, > > >>SELECT DISTINCT table1.tid, table1.name, table1.description FROM ... >> >>Does it equal to the scenario 2 or 3? >> > > Three. > > >>I am thinking SELECT DISTINCT table1.tid is just a variation (or the >> other way around) of SELECT DISTINCT ON (table1.tid), is that right? >> > > Wrong. SELECT DISTINCT ON table1.tid takes the table1.tid field and > the first related other data it can find. SELECT DISTINCT looks for > the unique combinaiton of all fields selected. In a multi-table, many > field query, the former is faster than the latter bceause less data is > being checked for uniqueness, and extra data is simply discarded. > > Tom, please correct me if I'm totally out on a limb, here. Is that(DISTINCT ON) SQL standard compliant or a Postgresql extension? -- Wei Weng Network Software Engineer KenCast Inc.
В списке pgsql-sql по дате отправления: