\set ECHO all
\timing on

\set N 10000000

-- date

select count(date_part('day', current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(date_part('month', current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(date_part('quarter', current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(date_part('week', current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(date_part('year', current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(date_part('decade', current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(date_part('century', current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(date_part('millennium', current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(date_part('julian', current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(date_part('isoyear', current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(date_part('dow', current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(date_part('isodow', current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(date_part('doy', current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(date_part('epoch', current_date + g * interval '1 day')) from generate_series(0, :N) g;

select count(extract(day from current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(extract(month from current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(extract(quarter from current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(extract(week from current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(extract(year from current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(extract(decade from current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(extract(century from current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(extract(millennium from current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(extract(julian from current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(extract(isoyear from current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(extract(dow from current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(extract(isodow from current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(extract(doy from current_date + g * interval '1 day')) from generate_series(0, :N) g;
select count(extract(epoch from current_date + g * interval '1 day')) from generate_series(0, :N) g;

-- time

select count(date_part('microseconds', localtime + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('milliseconds', localtime + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('second', localtime + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('minute', localtime + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('hour', localtime + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('epoch', localtime + g * interval '1 second')) from generate_series(0, :N) g;

select count(extract(microseconds from localtime + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(milliseconds from localtime + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(second from localtime + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(minute from localtime + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(hour from localtime + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(epoch from localtime + g * interval '1 second')) from generate_series(0, :N) g;

-- timetz

select count(date_part('microseconds', current_time + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('milliseconds', current_time + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('second', current_time + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('minute', current_time + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('hour', current_time + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('timezone_minute', current_time + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('timezone_hour', current_time + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('epoch', current_time + g * interval '1 second')) from generate_series(0, :N) g;

select count(extract(microseconds from current_time + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(milliseconds from current_time + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(second from current_time + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(minute from current_time + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(hour from current_time + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(timezone_minute from current_time + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(timezone_hour from current_time + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(epoch from current_time + g * interval '1 second')) from generate_series(0, :N) g;

-- timestamp

select count(date_part('microseconds', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('milliseconds', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('second', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('minute', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('hour', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('day', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('month', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('quarter', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('week', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('year', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('decade', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('century', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('millennium', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('julian', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('isoyear', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('dow', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('isodow', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('doy', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('epoch', localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;

select count(extract(microseconds from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(milliseconds from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(second from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(minute from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(hour from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(day from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(month from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(quarter from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(week from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(year from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(decade from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(century from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(millennium from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(julian from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(isoyear from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(dow from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(isodow from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(doy from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(epoch from localtimestamp + g * interval '1 second')) from generate_series(0, :N) g;

-- timestamptz

select count(date_part('microseconds', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('milliseconds', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('second', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('minute', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('hour', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('day', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('month', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('quarter', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('week', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('year', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('decade', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('century', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('millennium', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('julian', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('isoyear', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('dow', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('isodow', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('doy', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('timezone_minute', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('timezone_hour', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('epoch', current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;

select count(extract(microseconds from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(milliseconds from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(second from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(minute from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(hour from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(day from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(month from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(quarter from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(week from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(year from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(decade from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(century from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(millennium from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(julian from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(isoyear from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(dow from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(isodow from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(doy from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(timezone_minute from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(timezone_hour from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(epoch from current_timestamp + g * interval '1 second')) from generate_series(0, :N) g;

-- interval

select count(date_part('microseconds', g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('milliseconds', g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('second', g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('minute', g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('hour', g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('day', g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('month', g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('quarter', g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('year', g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('decade', g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('century', g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('millennium', g * interval '1 second')) from generate_series(0, :N) g;
select count(date_part('epoch', g * interval '1 second')) from generate_series(0, :N) g;

select count(extract(microseconds from g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(milliseconds from g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(second from g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(minute from g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(hour from g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(day from g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(month from g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(quarter from g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(year from g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(decade from g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(century from g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(millennium from g * interval '1 second')) from generate_series(0, :N) g;
select count(extract(epoch from g * interval '1 second')) from generate_series(0, :N) g;
