Hello, i have RADIUS accounting table with about 2 millions records.
I am trying to run report and i cannot change nested loop order, PG
selects to run on smaller table(carriernetworks) but i want to make it
run once on the huge one(radacct)
and join with smaller one.
SELECT username,
round(extract(epoch from SUM(acctsessiontime))/3600,2) as usage
FROM radacct a,
carriernetworks n
WHERE framedipaddress <> '' AND
acctstoptime BETWEEN '2002-09-30 0:0' AND '2002-10-30 0:0' AND
framedipaddress::TEXT::INET << n.network AND
n.carrier = 'Partner'
GROUP BY username
HAVING sum(acctsessiontime)/3600 > 190;
NOTICE: QUERY PLAN:
Aggregate (cost=200254241.62..200254435.04 rows=2579 width=62)
-> Group (cost=200254241.62..200254306.10 rows=25789 width=62)
-> Sort (cost=200254241.62..200254241.62 rows=25789
width=62)
-> Nested Loop (cost=200000000.00..200252352.01
rows=25789 width=62)
-> Seq Scan on carriernetworks n
(cost=100000000.00..100000004.65 rows=67 width=12)
-> Index Scan using radacct_stoptime_idx on
radacct a (cost=0.00..3754.83 rows=770 width=50)