Как минимум чтобы проверить есть такой емейл если емейл
$post->comments()->where('status', 1)->get();
$post->comments()->where('status', 0)->get();
Seq Scan on public.events (cost=0.00..557815.25 rows=382 width=191) (actual time=5.439..1858.064 rows=382 loops=1)
Output: events.id, events.title, events.hash, events.date_from, events.date_to, events.class_room_id, events.created_at, events.updated_at, events.name_class_teacher, events.number_student, events.phone_class_teacher, events.email_class_teacher, events.date_rise_in_price, events.percent_rise_in_price, (SubPlan 1)
Buffers: shared hit=109940
SubPlan 1
-> Limit (cost=1460.20..1460.21 rows=1 width=8) (actual time=4.861..4.862 rows=1 loops=382)
Output: (count(*))
Buffers: shared hit=109928
-> Aggregate (cost=1460.20..1460.21 rows=1 width=8) (actual time=4.860..4.860 rows=1 loops=382)
Output: count(*)
Buffers: shared hit=109928
-> Nested Loop (cost=1418.47..1459.97 rows=93 width=0) (actual time=4.824..4.858 rows=13 loops=382)
Buffers: shared hit=109928
-> HashAggregate (cost=1418.18..1419.26 rows=108 width=4) (actual time=4.814..4.816 rows=15 loops=382)
Output: order_photos.order_id
Group Key: order_photos.order_id
Buffers: shared hit=92821
-> Hash Semi Join (cost=715.22..1417.91 rows=108 width=4) (actual time=1.669..4.797 rows=95 loops=382)
Output: order_photos.order_id
Hash Cond: (order_photos.photo_id = photos.id)
Buffers: shared hit=92821
-> Seq Scan on public.order_photos (cost=0.00..598.05 rows=36505 width=8) (actual time=0.002..1.951 rows=36348 loops=353)
Output: order_photos.id, order_photos.count, order_photos.photo_format_id, order_photos.order_id, order_photos.photo_id, order_photos.created_at, order_photos.updated_at
Buffers: shared hit=82249
-> Hash (cost=707.97..707.97 rows=580 width=8) (actual time=0.166..0.166 rows=493 loops=382)
Output: photos.id
Buckets: 1024 Batches: 1 Memory Usage: 8kB
Buffers: shared hit=10572
-> Index Scan using photos_event_id_index on public.photos (cost=0.42..707.97 rows=580 width=8) (actual time=0.007..0.117 rows=493 loops=382)
Output: photos.id
Index Cond: ((photos.event_id IS NOT NULL) AND (photos.event_id = events.id))
Filter: (photos.category_id IS NOT NULL)
Buffers: shared hit=10572
-> Index Scan using orders_pkey on public.orders (cost=0.28..0.37 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=5691)
Output: orders.id
Index Cond: (orders.id = order_photos.order_id)
Filter: ((orders.status)::text <> 'not_paid'::text)
Rows Removed by Filter: 0
Buffers: shared hit=17107
Planning time: 0.394 ms
Execution time: 1858.160 ms
Seq Scan on public.events (cost=0.00..557815.25 rows=382 width=191) (actual time=5.387..1834.601 rows=382 loops=1)
(actual time=0.163..0.164 rows=493 loops=382