Answer the question
In order to leave comments, you need to log in
Postgres query optimization?
PostgreSQL 9.3.3 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4), 64-bit
/------ 04.02.2015 8:40:12 --------/
EXPLAIN ANALYZE SELECT EXTRACT(EPOCH FROM "F_Date"), "F_ConvertedValue", "F_TagName_ID" FROM "SC_Tag"."T_TagData" where "F_Date" > (localtimestamp - interval'1 hour') and "F_TagName_ID" in (73,72,39,64,76,75)
ORDER BY "F_Date" asc;;
/* Результат : "LOG: duration: 11276.442 ms statement: EXPLAIN ANALYZE SELECT EXTRACT(EPOCH FROM "F_Date"), "F_ConvertedValue", "F_TagName_ID" FROM "SC_Tag"."T_TagData" where "F_Date" > (localtimestamp - interval'1 hour') and "F_TagName_ID" in (73,72,39,64,76,75) ORDER BY "F_Date" asc;;
возвращено записей: 7 (выполнено: 11,279 с; всего: 11,279 с)" */
/------ 04.02.2015 8:49:52 --------/
EXPLAIN ANALYZE SELECT EXTRACT(EPOCH FROM "F_Date"), "F_ConvertedValue", "F_TagName_ID" FROM "SC_Tag"."T_TagData" where "F_Date" > (localtimestamp - interval'1 hour') and "F_TagName_ID" in (73,72,39,64,76,75)
--ORDER BY "F_Date" asc;;
/* Результат : "LOG: duration: 9359.324 ms statement: EXPLAIN ANALYZE SELECT EXTRACT(EPOCH FROM "F_Date"), "F_ConvertedValue", "F_TagName_ID" FROM "SC_Tag"."T_TagData" where "F_Date" > (localtimestamp - interval'1 hour') and "F_TagName_ID" in (73,72,39,64,76,75)
возвращено записей: 4 (выполнено: 9,360 с; всего: 9,375 с)" */
Answer the question
In order to leave comments, you need to log in
des1roer : CREATE INDEX as far as I understand creates indexes for the most frequently accessed data. but if the data is dynamic then how to do it and will it help
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question