hsqldb

Huge performance difference when using group by vs distinct

假装没事ソ 提交于 2019-11-26 05:22:05
问题 I am performing some tests on a HSQLDB server with a table containing 500 000 entries. The table has no indices. There are 5000 distinct business keys. I need a list of them. Naturally I started with a DISTINCT query: SELECT DISTINCT business_key FROM memory WHERE concept <> \'case\' or attrib <> \'status\' or value <> \'closed\' It takes around 90 seconds!!! Then I tried using GROUP BY : SELECT business_key FROM memory WHERE concept <> \'case\' or attrib <> \'status\' or value <> \'closed\'