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

  • 51 years of Star Trek  geek
  • Ergonomics never were so amusing geek
  • Not all problems require automation geek
  • Follow-up: shortest abstract geek
  • Brushing off the old coding skills geek
  • Google autocomplete questions 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

There are, it has been said, two types of people in the world. There are those who, when presented with a glass that is exactly half full, say: this glass is half full. And then there are those who say: this glass is half empty. The world *belongs*, however, to those who can look at the glass and say: What's up with this glass? Excuse me? Excuse *me*? This is my glass? I don't *think* so. My glass was full! *And* it was a bigger glass!
--(Terry Pratchett, The Truth)

Random Posts

  • Pandemic confinement, week 2
  • I foresee weirdness today
  • It’s for my own good.
  • All planned out, over and done with!
  • I want me some of that!
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