Hello!
WHERE boolean and WHERE boolean = TRUE have no difference.
The actual problem is usage of
OR, H2 is unable to use indexes in such conditions. Take a look on execution plan produced by the
EXPLAIN command:
SELECT
"SEQUENCE",
"MEM",
"MEMADDR",
"MEMVALUE",
"MEMREAD"
FROM "PUBLIC"."DATA"
/* PUBLIC.DATA.tableScan */
WHERE "MEM"
OR "IRQREQUEST"
ORDER BY 1
So you need to convert this query into query with a UNION:
(select sequence, mem, memaddr, memvalue, memRead from data where mem union select sequence, mem, memaddr, memvalue, memRead from data where irqRequest) order by sequence;
This query can use indexes, see its execution plan:
(SELECT
"SEQUENCE",
"MEM",
"MEMADDR",
"MEMVALUE",
"MEMREAD"
FROM "PUBLIC"."DATA"
/* PUBLIC.MEM: MEM = TRUE */
WHERE "MEM")
UNION
(SELECT
"SEQUENCE",
"MEM",
"MEMADDR",
"MEMVALUE",
"MEMREAD"
FROM "PUBLIC"."DATA"
/* PUBLIC.IRQREQUEST: IRQREQUEST = TRUE */
WHERE "IRQREQUEST")
ORDER BY 1