From: | "Yura Gal" <yuragal(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | GiST/GIN index for field of type VARCHAR[] |
Date: | 2008-04-03 15:38:49 |
Message-ID: | 3b6c69d80804030838k5c2bc14axd168bae52118103e@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I have following table:
CREATE TABLE t1 (
"name" VARCHAR(500) NOT NULL,
"lid" INTEGER NOT NULL,
"accs" VARCHAR(20)[] NOT NULL
CONSTRAINT "t1_lid_key" UNIQUE("lid")
);
I interested in the possibility to speed-up search for rows like this:
SELECT lid
FROM t1
WHERE accs && ARRAY['item1','item2'...]::VARCHAR[];
For sure, I can use the typical way of data normalization to decrease
query time:
CREATE TABLE t2(
"lid" INTEGER NOT NULL,
"acc" VARCHAR(20) NOT NULL
);
with: t2.lid = t1.lid & t1.accs @> ARRAY[t2.acc]
and create hash index on acc.
Then I could SELECT lid FROM t2 WHERE acc IN(item1,item2);
But it's more interesting to implement GiST/GIN indexes for this purpose.
And what type of index is the most suitable if VARCHAR[] arrays are
1-dimensional and contain from 1 to 20000 elements?
Thanks in advance.
--
Best regards. Yuri.
mailto: yuragal(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Marcin Krawczyk | 2008-04-03 17:00:26 | connections between servers |
Previous Message | A. Kretschmer | 2008-04-03 11:09:19 | Re: BROBLEM IN BETWEEN QUERY (plpgsql) |