I have table "listing_data" which is about 150.000 rows. I have problem with filtering and sorting when the data comes from JSON. I have added keys on each column which needed for filtering and sorting.
However, as one column "data" used to store JSON use "TEXT" so I cannot add index there. I am trying to run this query
SELECT
id,
title,
slug,
description,
uniqueId,
data,
images,
view,
contact,
lastSync,
status,
sold,
waktu,
FLOOR(
JSON_UNQUOTE(
JSON_EXTRACT(data, '$.price')
)/ 100000000
)* 100 AS rangePrice,
COUNT(id) AS total
FROM
listing_data
WHERE
JSON_UNQUOTE(
JSON_EXTRACT(data, '$.subCategory')
)= 'rumah'
and JSON_UNQUOTE(
JSON_EXTRACT(data, '$.type')
)= 'dijual'
and LOWER(
JSON_UNQUOTE(
JSON_EXTRACT(data, '$.province')
)
)= 'lampung'
and LOWER(
JSON_UNQUOTE(
JSON_EXTRACT(data, '$.regency')
)
)= 'bandar lampung'
and LOWER(
JSON_UNQUOTE(
JSON_EXTRACT(data, '$.district')
)
)= 'way halim'
GROUP BY
JSON_UNQUOTE(
JSON_EXTRACT(data, '$.price')
)
ORDER BY
rangePrice ASC
LIMIT
0, 20
It took 2.8148 seconds to run. Is there any solution how to make it faster? I want to know if there is a way to add index into TEXT column.