Hey everyone,
I'm pretty new to the SQL and need some help with a certain task. I have a query that is called by our Flex/Java code that joins multiple tables to get information. Upon running an Explain Analyze, I've seen that the query takes over 15 minutes which sometimes even times out if the site is under heavy traffic. What I am trying to do is to create a rule, or a trigger, that sees if the query is called and selects the data from the materialized view table instead. I tried implementing a rule for this, but was having a hard time when I received errors when trying to join multiple tables in the rule. Basically is there a way, whether it be a rule, trigger, or anything else I have not looked into, for me to see if a certain query gets executed that I can replace that query with one from another table? Thanks in advance.
Example of the query:
select
player_id,
player_names,
player_level,
current_location
from
server_info
join players using (player_id)
join locations using (location_id)
where
current_location = 'Central Hub'