Unix Technical Forum

GiST/GIN index for field of type VARCHAR[]

This is a discussion on GiST/GIN index for field of type VARCHAR[] within the pgsql Sql forums, part of the PostgreSQL category; --> I have following table: CREATE TABLE t1 ( "name" VARCHAR(500) NOT NULL, "lid" INTEGER NOT NULL, "accs" VARCHAR(20)[] NOT ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 06:01 PM
Yura Gal
 
Posts: n/a
Default GiST/GIN index for field of type VARCHAR[]

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@gmail.com

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:23 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com