Skip to content

Instantly share code, notes, and snippets.

@frankwiles
Created September 14, 2012 18:54
Show Gist options
  • Save frankwiles/3723916 to your computer and use it in GitHub Desktop.
Save frankwiles/3723916 to your computer and use it in GitHub Desktop.
Index on first 5 characters of a column
CREATE TABLE song (
title varchar(20),
);
CREATE INDEX firstfive_idx ON song WHERE substring(title, 0, 6);
SELECT * FROM song WHERE substring(title, 0, 6) = 'foobar1' AND title='foobar1bazbazwheeheee!';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment