Skip to content

Instantly share code, notes, and snippets.

@Kimtaro
Created December 6, 2011 07:01
Show Gist options
  • Save Kimtaro/1437129 to your computer and use it in GitHub Desktop.
Save Kimtaro/1437129 to your computer and use it in GitHub Desktop.
Some helpful SQL
SELECT * FROM table PROCEDURE ANALYSE(0,0)\G
-- "ANALYSE() examines the result from a query and returns an analysis of the results that suggests optimal data types for each column that may help reduce table sizes."
SELECT COUNT(DISTINCT(SUBSTR(column, 1, 22))) / COUNT(DISTINCT(column)) * 100 FROM table;
-- Figures out index coverage with the given index length (22 here).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment