oh my god, I am going to throw my computer out of the window
I cannot make this work no matter what I do.
I have multiple documents (200 million) of the format: (filtered by app_primary_genre_id = 1 - will result in 200k documents )
{
“country_code”: “us”,
“sub_type”: “app”,
“redacted”: {
“app_name”: “dark war”,
“app_primary_genre_id”: 1,
"app_provider_uuid": "eecefa65-12bd-45d5-93b8-eef72c83ed24",
"release_date": 1234,
"user_rating": 4.23
}
“key”: “meta:bc9f7bc7-ad0a-4f91-a213-357872d34d8c:is”,
“created_timestamp”: 1602820362,
“type”: “tracker-app”,
“version”: 2,
"app_uuid": "bc9f7bc7-ad0a-4f91-a213-357872d34d8c",
“updated_timestamp”: 1611807733
}
and another (100k) of format:
{
“sub_type”: “app-extra”,
“key”: “meta:bc9f7bc7-ad0a-4f91-a213-357872d34d8c:e:1”,
“created_timestamp”: 1602820362,
“type”: “tracker-app”,
"i_genre_id": "1001",
“version”: 2,
“updated_timestamp”: 1611807733
}
I am trying to make a query to join and filter these two type of documents:
SELECT META(a).id,
FROM `bucket` a LEFT
JOIN `bucket` e ON a.app_uuid = e.app_uuid
AND e.sub_type="app-extra"
WHERE a.sub_type="app"
AND a.country_code = "us"
AND a.redacted.app_primary_genre_id = 1
AND a.redacted.app_provider_uuid= "eecefa65-12bd-45d5-93b8-eef72c83ed24" /* (this is optional) */
AND a.redacted.release_date <= 1234 /* (this is optional) */
AND a.redacted.user_rating <= 3 /* (this is optional) */
AND a.redacted.app_name LIKE "%dark%" /* (this is optional) */
AND e.i_genre_id LIKE "2%" /* (this is optional) */
I have created all the recommended queries (including the covering ones), the results (8 in total) of this query takes 2 seconds. Which is unacceptably high, but If I do a count(*)
SELECT count(*)
FROM `bucket` a LEFT
JOIN `bucket` e ON a.app_uuid = e.app_uuid
AND e.sub_type="app-extra"
WHERE a.sub_type="app"
AND a.country_code = "us"
AND a.redacted.app_primary_genre_id = 1
AND a.redacted.app_provider_uuid= "eecefa65-12bd-45d5-93b8-eef72c83ed24" /* (this is optional) */
AND a.redacted.release_date <= 1234 /* (this is optional) */
AND a.redacted.user_rating <= 3 /* (this is optional) */
AND a.redacted.app_name LIKE "%dark%" /* (this is optional) */
AND e.i_genre_id LIKE "2%" /* (this is optional) */
I get the results in tens of minutes, so, clearly, I am doing something wrong.
I have created so many indexes (lost count), based on your https://index-advisor.couchbase.com/indexadvisor/ but also on the index recommendations in the query result page (“Advice” tab). I don’t know what else to do, this is not working!!
I am trying to use this type of queries on a paginated search results page for a web application. So, I will also need to implement some kind of pagination
I don’t understand what is wrong and how can this be improved, but I feel I am going crazy.
Is it possible to get anybody from this forum to pay to help me with all these queries? (probably will be cheaper than madness medication)