Created
July 29, 2016 13:56
-
-
Save lukeasrodgers/922ef0e6209c121c29f40fc9b8beb58e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://bonesmoses.org/2016/07/15/pg-phriday-a-postgres-persepctive-on-mongodb/ | |
CREATE TABLE sensor_log ( | |
id SERIAL NOT NULL PRIMARY KEY, | |
location VARCHAR NOT NULL, | |
reading BIGINT NOT NULL, | |
reading_date TIMESTAMP NOT NULL | |
); | |
\timing | |
INSERT INTO sensor_log (id, location, reading, reading_date) | |
SELECT s.id, s.id % 1000, s.id % 100, | |
CURRENT_DATE - ((s.id * 10) || 's')::INTERVAL | |
FROM generate_series(1, 1000000) s(id); | |
TIME: 7236.906 ms | |
CREATE INDEX idx_sensor_log_date | |
ON sensor_log (reading_date); | |
TIME: 804.044 ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment