By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
CREATE TABLE
INSERT 0 2
CREATE FUNCTION
ERROR: function crosstab(text, unknown) does not exist LINE 1: SELECT * FROM crosstab(' ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. QUERY: SELECT * FROM crosstab(' SELECT extract(week from starts) as week, extract(dow from starts) as dow, count(*) FROM events WHERE extract(month from starts) = ' || mth || ' AND extract(year from starts) = ' || yr || ' GROUP BY week, dow ORDER BY week, dow', 'SELECT * FROM generate_series(0,6) AS dow' ) AS ( week int, sun int, mon int, tue int, wed int, thu int, fri int, sat int ) ORDER BY week CONTEXT: PL/pgSQL function get_month_events(integer,integer) line 3 at RETURN QUERY