I have a simple logs table with about 500,000 rows, table structure is
TABLE logs
(
id serial NOT NULL,
username character varying(32),
user_id integer,
description text NOT NULL,
"time" timestamp with time zone DEFAULT now(),
referrer character varying(128),
"type" character varying(25)
)
The most common operation in terms of querying this table for contents of the description column. Typical query is...
SELECT username , time , description FROM logs WHERE description ~* 'some text' ORDER by time DESC
This takes anywhere from 8 ~ 20 seconds, to bring back results. Is there any other method to optimize the table or query that would produce faster results. I'm on 8.2 Portgresql .