As you can see I have pretty simple SQL statement:
SELECT DISTINCT("CITY" || ' | ' || "AREA" || ' | ' || "REGION") AS LOCATION
FROM youtube
The youtube table which I use in query has ~ 25 million records. The query takes a very long time to complete (~25 seconds). I'm trying to speed up the request.
I create an index as shown below but my query higher still takes the same time to complete. Whatdid I do wrong? By the way, is it better to use “partitioning” in my case?
CREATE INDEX location_index ON youtube ("CITY", "AREA", "REGION")
EXPLAIN returns:
Unique (cost=5984116.71..6111107.27 rows=96410 width=32)
-> Sort (cost=5984116.71..6047611.99 rows=25398112 width=32)
Sort Key: ((((("CITY" || ' | '::text) || "AREA") || ' | '::text) || "REGION"))
-> Seq Scan on youtube (cost=0.00..1037365.24 rows=25398112 width=32)
@george-joseph QUERY PLAN of your script:

select concat(city, '|', area, '|', region) as location from (select city, area, region, count(*) youtube group by city, area, region) x;? How long does that take?youtubetable which I use has ~ 25 million records. New data is loaded into the table every 5 minutes. Maybe it's better to createindexandpartitionto table? My main question was about that. What do you think about that?