Diskuse:PostgreSQL SQL Tricks IV

Z PostgreSQL
Verze z 15. 9. 2013, 07:38, kterou vytvořil imported>Pavel (Pavel přesunul stránku Diskuse:PostgreSQL SQL Tricks na Diskuse:PostgreSQL SQL Tricks IV)
(rozdíl) ← Starší verze | zobrazit aktuální verzi (rozdíl) | Novější verze → (rozdíl)
Skočit na navigaci Skočit na vyhledávání

moved from main page

select version(); -- "PostgreSQL 8.4.1 on x86_64-pc-linux-gnu, compiled by GCC gcc-4.3.real (Debian 4.3.4-2) 4.3.4, 64-bit"

explain analyze SELECT EXTRACT(EPOCH FROM now())::integer  FROM generate_series(1, 10000000); -- "Total runtime: 9842.774 ms"
explain analyze SELECT now()::abstime::integer             FROM generate_series(1, 10000000); -- "Total runtime: 8025.998 ms" (! -18%)

explain analyze SELECT to_timestamp(1260348132)::timestamp FROM generate_series(1, 10000000); -- "Total runtime: 8926.712 ms"
explain analyze SELECT 1260348132::abstime::timestamp      FROM generate_series(1, 10000000); -- "Total runtime: 8667.587 ms" (-3%)

Using a depracated feature is wrong in any case and it is a potential risk. What more both variants are very fast - the difference for ten milions calling is 2 seconds (for you). Really it isn't reason for using a depracated feature. If you want discus about this topic, please - mail me - pavel.stehule at gmail.com. I'll move this discus to discus place tomorrow.