Create Full Text Search (FTS)
ALTER TABLE codepoint_open.codepoint_open ADD COLUMN search_fts tsvector;
COMMIT;
UPDATE codepoint_open.codepoint_open SET search_fts = to_tsvector('english', single_postcode);
COMMIT;
CREATE INDEX idx_codepoint_open_search_fts ON codepoint_open.codepoint_open USING GIN(search_fts);
--The following is an example query
SELECT * FROM codepoint_open.codepoint_open WHERE search_fts @@ to_tsquery('english', 'RH1:*');
Updated less than a minute ago