Victory Road Archive

You are viewing an archive of Victory Road.

Victory Road closed on January 8, 2018. Thank you for making us a part of your lives since 2006! Please read this thread for details if you missed it.

Technology → SQL Indexes

Page 1 of 1

1. FreezeWarp said on June 26, 2010, 09:53:02 PM (-07:00)

Kyurem
2,186 posts

Being a relative n00b at SQL, optimization has never been my thing. Its complicated, its usually limited in applicable scenarios, and frankly its time consuming. Of course, eventually SQL optimization is a must, but there's one cheater's solution before you come to that road: SQL indexes. Using an index, or two or three indexes, allows much faster execution of common queries all across the board. In an example today:

Code:
SELECT COUNT(op.id) AS total_adopts, SUM(op.clicks) AS clicks, sum(op.views) AS views, user.username, user.userid FROM zf_ownedPokemon AS op, user WHERE op.owner = user.userid GROUP BY op.owner ORDER BY total_adopts DESC LIMIT 30
With an index only on "op.id", the query took nearly 20 seconds. With the index added, the query took just under a second: a 20 times optimization. A metaphore used at Database Journal describes the well: it would take you forever to find what you need in a large technical manual, but with an index, its much easier.

2. KingOfKYA said on June 27, 2010, 01:19:36 PM (-07:00)

Volcarona
523 posts

Its not just you me and cat are havening optimization issues too .
the chat still has to be dumped to a archive off the main table every few weeks.

However after lots of looking our biggest gains were achieved my simply useing innodb and optimizing mysql config.

Page 1 of 1

User List - Contact - Privacy Statement - Lycanroc.Net