Quote:
Originally Posted by Michelle
I don't understand 
Can you please take a look at my referrer statistics hack and tell me what do you think about the queries? :nervous:
Please? :nervous:
|
You should recommend placing an index on referrerid for your queries to work better and not result in table scans.
Code:
ALTER TABLE `user` ADD INDEX ( `referrerid` )
As the user table is actually very rarely updated, at least compared to other tables, the additional index will decrease the overhead of your hack and not increase the creation or editing times of users substantially.
Read this article for more information:
http://www.databasejournal.com/featu...0897_1382791_2
Even though your hack only has two queries, it completes two table scans. Table Scans are bad because it copies the entire table into memory and locks it until completed. This means no one's records can be updated or created while it is locked. On a small forum this may take milliseconds as MySQL looks at every record to see if it matches. On large forums it can take several seconds.