Query time grows 6 times with just 200 more entries


I am doing some test about objected-relational mapping and something odd came up: when I implement a simple hierarchy test using one table per subclass, with two subclasses, I get a query time of 218.44ms when there are 12000 lines splited in the two tables, but a query time of 1207.56 when I add more 200 lines!
Why is there such a big difference with only 200 aditonal lines? Before 12000 and after 12200 the query time grows slowly.
The query I am running basically makes an union between the two tables and then select one entry by the id.

The querry is generated by Hibernate.


Please post:

  1. tables structure
  2. select query
  3. explain for query in point 2, eg:
    explain select * from table …

id select_type table type possible_keys key key_len ref rows Extra