Re: store A LOT of 3-tuples for comparisons

Поиск
Список
Период
Сортировка
От Shane Ambler
Тема Re: store A LOT of 3-tuples for comparisons
Дата
Msg-id 47BFD107.8050007@Sheeky.Biz
обсуждение исходный текст
Ответ на Re: store A LOT of 3-tuples for comparisons  (Matthew <matthew@flymine.org>)
Ответы Re: store A LOT of 3-tuples for comparisons  (Moritz Onken <onken@houseofdesign.de>)
Список pgsql-performance
Matthew wrote:
> On Fri, 22 Feb 2008, Moritz Onken wrote:

>> I thought of doing all the inserts without having an index and without
>> doing the check whether the row is already there. After that I'd do a
>> "group by" and count(*) on that table. Is this a good idea?
>
> That sounds like the fastest way to do it, certainly.

Yeah I would load the data into a temp 3-column table and then
INSERT INTO mydatatable SELECT w1,w2,w3,count(*) GROUP BY w1,w2,w3
then
CREATE UNIQUE INDEX idx_unique_data ON mydatatable (w1,w2,w3)
if you plan to continue adding to and using the data.

If this is to be an ongoing data collection (with data being added
slowly from here) I would probably setup a trigger to update the count
column.


I am also wondering about the ordering and whether that matters.
Can you have "he", "can", "drink" as well as "drink", "he", "can"
and should they be considered the same? If so you will need a different
tactic.



--

Shane Ambler
pgSQL (at) Sheeky (dot) Biz

Get Sheeky @ http://Sheeky.Biz

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

Предыдущее
От: "Dean Gibson (DB Administrator)"
Дата:
Сообщение: Re: Q on views and performance
Следующее
От: Moritz Onken
Дата:
Сообщение: Re: store A LOT of 3-tuples for comparisons