PostgreSQL & PHP Tutorials - Database Design Issues - Final Query
Viewing page 5 of 5
« |
Back | Next | »
Now that we're updating the information instead of using a subquery and left join, we end up with a much simpler query:
SELECT forumid, forumtitle, forumdescription, forumnode, createdate, threadcount, postcount FROM myforum_forums ORDER BY forumnode ASC;
We might get a slight performance decrease when adding threads or posts to a forum since the database has to process and run the trigger (which in turn updates the other database table), but since most of the time we're only selecting records, this is totally acceptable and gives us a huge performance increase in the vast majority of cases.
We don't lose anything with this particular approach, or make the database contain a lot of redundant data or make it difficult to update, we get the database to keep itself up to date.
Of course, depending on your application, database design and the types of queries you are running, there will be other things to consider. If you find performance becoming an issue, maybe an approach like this will save the day!
Viewing page 5 of 5
« |
Back | Next | »
Avg Rating: 3
Vote Count: 19
