Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I index DateTime in SQLite?

Tags:

sql

sqlite

Will it make it faster to find date > a certain date?

like image 335
tofutim Avatar asked Jun 01 '11 01:06

tofutim


People also ask

Should you index a date field?

Adding an index on date column definitely increases performance.

Does SQLite have datetime?

SQlite does not have a specific datetime type. You can use TEXT , REAL or INTEGER types, whichever suits your needs.

Does SQLite use index?

SQLite uses B-tree for organizing indexes. Note that B stands for balanced, B-tree is a balanced tree, not a binary tree. The B-tree keeps the amount of data at both sides of the tree balanced so that the number of levels that must be traversed to locate a row is always in the same approximate number.

How does SQLite handle dates?

The SQLite date() function is used to calculate the date and return it in the format 'YYYY-MM-DD'. The SQLite datetime() function is used to calculate a date/time value, and return it in the format 'YYYY-MM-DD HH:MM:SS'. The SQLite julianday() function returns the date according to julian day.


1 Answers

In general yes, but keep in mind that SQLite only uses one index per-table (except in the case of OR clauses). Always use EXPLAIN to find out how the engine will process a given query.

like image 50
AJ. Avatar answered Oct 07 '22 14:10

AJ.