Re: low cardinality column

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: low cardinality column
Дата
Msg-id 200310021137.22119.josh@agliodbs.com
обсуждение исходный текст
Ответ на low cardinality column  ("Rong Wu" <rwu@cbnco.com>)
Список pgsql-performance
Rong,

> I have a select like this:
>
> SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=0;

Simple workaround:

Create an mulit-column index on transactiontypeid, transactionid.

SELECT transactionid FROM cbtransaction
WHERE transactiontypeid=0
ORDER BY transactionid DESC LIMIT 1;

This approach will use the index.

Of course, if the reason you are selecting the max id is to get the next id,
there are much better ways to do that.

--
-Josh Berkus
 Aglio Database Solutions
 San Francisco


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

Предыдущее
От: "Rong Wu"
Дата:
Сообщение: low cardinality column
Следующее
От: Rod Taylor
Дата:
Сообщение: Re: low cardinality column