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

  • Gut macrobiome geek
  • Wow! where did all my money go? geek
  • Google autocomplete questions geek
  • Oldie-friendly tech geek
  • I can stop any time I want, I just don’t want to. geek
  • Well, that was exciting! 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 Patrician was a pragmatist. He never tried to fix things that worked. Things that didn't work, however, got broken.
--(Terry Pratchett, Soul Music)

Random Posts

  • [recipe] Bloody Stupid Mary
  • New Playboy for the snapchat generation
  • Cleaning house
  • Some clever sods
  • Curse you, metabolism!
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