QUERY PLAN
Limit (cost=149.40..149.41 rows=2 width=48)
-> Sort (cost=149.40..149.41 rows=2 width=48)
Sort Key: s.created_at DESC
-> Subquery Scan on s (cost=149.34..149.39 rows=2 width=48)
-> GroupAggregate (cost=149.34..149.37 rows=2 width=48)
Group Key: pip.description
-> Sort (cost=149.34..149.34 rows=2 width=48)
Sort Key: pip.description
-> Append (cost=103.04..149.33 rows=2 width=48)
-> GroupAggregate (cost=103.04..103.06 rows=1 width=52)
Group Key: pip.description
-> Sort (cost=103.04..103.04 rows=1 width=52)
Sort Key: pip.description
-> Nested Loop Left Join (cost=0.28..103.03 rows=1 width=52)
-> Seq Scan on tbl_purchase_invoice_products pip (cost=0.00..94.72 rows=1 width=48)
Filter: (description ~~* '%法国的%'::text)
-> Index Scan using tbl_purchase_contract_invoices_pkey on tbl_purchase_contract_invoices pci (cost=0.28..8.30 rows=1 width=12)
Index Cond: (id = pip.purchase_invoice_id)
-> GroupAggregate (cost=46.23..46.25 rows=1 width=45)
Group Key: pip_1.description
-> Sort (cost=46.23..46.23 rows=1 width=45)
Sort Key: pip_1.description
-> Nested Loop Left Join (cost=0.28..46.22 rows=1 width=45)
-> Seq Scan on tbl_sales_invoice_products pip_1 (cost=0.00..37.91 rows=1 width=41)
Filter: (description ~~* '%法国的%'::text)
-> Index Scan using tbl_sales_contract_invoices_pkey on tbl_sales_contract_invoices pci_1 (cost=0.28..8.30 rows=1 width=12)
Index Cond: (id = pip_1.sales_invoice_id)