Re: Could use some advice on search architecture - Mailing list pgsql-general

From Ron Pasch
Subject Re: Could use some advice on search architecture
Date
Msg-id 53550A42.8010801@ronpasch.nl
Whole thread Raw
In response to Could use some advice on search architecture  (Ron Pasch <postgresql@ronpasch.nl>)
List pgsql-general
I ended up running some tests using 5 million rows of products. I used
about 5 properties that a product should always be matched to, and then
I used the following in the select;

(CASE property1 in (option1, option2, option3, etc) WHEN TRUE THEN 1
ELSE 0 END)
+ (CASE property2 in (option1, option2, option3, etc) WHEN TRUE THEN 1
ELSE 0 END)
+ (CASE property3 in (option1, option2, option3, etc) WHEN TRUE THEN 1
ELSE 0 END)
...
AS numberOfMatchingProperties

That way I can use the number of matching properties in the order by
clause and have the properties that must always match filter out the
bulk of the 5 million records.

The tests that I've done return around 100.000 records in about 100 to
150 milliseconds using this technique, and using OFFSET and LIMIT to
paginate those by about 15 records each time is very very fast.

This I can live with :) Thx for letting me pick your brains on this a
little.

Cheers,
Ron



pgsql-general by date:

Previous
From: Dorian Hoxha
Date:
Subject: Re: Altering array(composite-types) without breaking code when inserting them and similar questions
Next
From: wd
Date:
Subject: Make basebackup use low level API and rsync