Skip to content
The beaver is a proud and noble animal

The beaver is a proud and noble animal

Notes from a bemused canuck

  • Home
  • About
  • Bookmarks
  • Pictures
  • Resume
  • Wine
  • Random Recipe
  • Toggle search form

On the value of database indexes

Posted on July 7, 2005 By admin

Been trying to wrap my head around a bug at work, why a simple database query never returned a result set and crashed the server. The query is a simple left join from a “term” table with 40K records to a “term_synonym” table with 140K records. It should be straightforward. It should work.

It didn't.

For a very, very stupid reason on my part.

I'd forgotten to create indexes on the tables and it was doing full table scans. That comes out to 5,600,000,000 iterations over the term_synonym table. No wonder it was slow.

After creating the index:

mysql> select count(*) from term t left join term_synonym ts on  t.term_id = ts.term_id;
+----------+
| count(*) |
+----------+
|   156746 |
+----------+
1 row in set (1.72 sec)

Um, ya, I suck.

  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Facebook (Opens in new window) Facebook
  • Share on Threads (Opens in new window) Threads
  • Share on Bluesky (Opens in new window) Bluesky
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Email a link to a friend (Opens in new window) Email
uncategorized Tags:geek

Post navigation

Previous Post: just FYI
Next Post: wish me luck

Related Posts

  • If I were a woman… geek
  • Powerpoint Karaoke geek
  • Move over D&D, this is B&B comics
  • Sign of the times geek
  • God bless this shit computers are evil
  • Optimized solution for periodic words geek

Power to the beaver!

Show me the beaver!
July 2005
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031
« Jun   Aug »

Quote of the day

The question seldom addressed is *where* Medusa had snakes. Underarm hair is an even more embarassing problem when it keeps biting the top of the deodorant bottle.
--(Terry Pratchett, Soul Music)

Random Posts

  • Hey, you! Yes, you! You’re awesome!
  • Why I should keep a reserve of gin in my desk
  • Cats, or Happy Birthday Katy!
  • Swissmas dinner
  • [recipe] Pouding Chômeur
reading leopard

Tags

bobble the little blue owl boobies brought to you by the fda cats chonk christmas comics computers are evil covid-19 dealing with idiots dilbert dog ducks galleries geek god bless the land of the free holidays house I am Canadian land of cheese and chocolate linked news lolcat london news from the stupid not my dog nsfw pets pictures potd2014 qotd random shit re-member recipes relationship shrill slice of life stress Tao the british way The Peanut things i miss travel video wine work

Archives

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2026 The beaver is a proud and noble animal.

Powered by PressBook Premium theme