Re: A fairly obvious optimization?

Поиск
Список
Период
Сортировка
От Zeugswetter Andreas SB SD
Тема Re: A fairly obvious optimization?
Дата
Msg-id 46C15C39FEB2C44BA555E356FBCD6FA4961DCF@m0114.s-mxs.net
обсуждение исходный текст
Ответ на A fairly obvious optimization?  ("Dann Corbit" <DCorbit@connx.com>)
Ответы Re: A fairly obvious optimization?  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-hackers
> The select(min) and select(max) took as long as the table scan to find
> the count.  It seems logical if a btree type index is available (such
> as pk_cnx_ds_sis_bill_detl_tb) where the most significant bit of the
> index is the column requested, it should be little more than a seek
> first or seek last in the btree.  Obviously, it won't work with a hashed
> index (which is neither here nor there).

In the meantime you can use:
select extr_stu_id from cnx_ds_sis_bill_detl_tb order by 1 desc limit 1; -- max
select extr_stu_id from cnx_ds_sis_bill_detl_tb order by 1 asc limit 1; -- min

I guess that is the reason why nobody felt really motivated to implement
this optimization. Besides these statements are more powerful, since they can fetch
other columns from this min/max row. The down side is, that this syntax varies across
db vendors, but most (all?) have a corresponding feature nowadays.

select first 1
select top 1 ...

This is actually becoming a FAQ :-)

Andreas


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Daniel
Дата:
Сообщение: Re: Kerberos principal to dbuser mapping
Следующее
От: Hannu Krosing
Дата:
Сообщение: Re: A fairly obvious optimization?