Database Reference
In-Depth Information
SELECT * FROM running_queries(1000,1024);
You may want to define a few convenience views for the variants you use most.
CREATE OR REPLACE VIEW running_queries_tiny AS
SELECT * FROM running_queries(5,25);
CREATE VIEW running_queries_full AS
SELECT * FROM running_queries(1000,1024);
You may even redefine the original view to use the first version of the function.
CREATE OR REPLACE VIEW running_queries AS
SELECT * FROM running_queries(5,25);
This is usually not recommended, but it demonstrates three important things:
• Views and functions can have exactly the same name
• You can get a circular reference by basing a function on a view and then
basing a view on that function
• If you get a circular reference this way, you can't easily change either
definition
To resolve this, simply avoid circular references.
Even without circular references, there is still a dependency on the view called from
the function. If, for instance, you need to add a column to show the application name
to the running_queries view. The function needs to change as well.
CREATE OR REPLACE VIEW running_queries AS
SELECT
CURRENT_TIMESTAMP - query_start as runtime,
pid,
usename,
waiting,
query,
application_name as appname
Search WWH ::




Custom Search