[prev] 21 [next]

Exercise 3: More accurate tuple counts

The earlier example:

create view pop("table",ntuples) as ...

gives estimated tuple counts which may not be accurate.

Write a PLpgSQL function that returns accurate counts:

create type TableInfo as (table text, ntuples int);
create function pop2() returns setof TableInfo ...

Hint: you will need to use dynamically-generated queries.