Answer the question
In order to leave comments, you need to log in
Why can the request just hang?
Hi all!
Can you please tell me why this request is stuck? Something I don't get at all:
SELECT COUNT(*) FROM gen_lenta WHERE lenta_id NOT IN (SELECT id FROM lenta_bundle)
Answer the question
In order to leave comments, you need to log in
SELECT COUNT(*)
FROM gen_lenta
left join lenta_bundle on lenta_bundle.id=lenta_id
where lenta_bundle.id is not null
Try this way. Usually works much faster than your approach.
It is also worth checking that you have indexes for all the required fields.
Конструкцию NOT IN лучше применять, если подзапрос возвращает менее десятка-двух записей. Эта конструкция при большом объёме данных сжирает кучу ресурсов, в том числе и оперативной памяти.
Используйте подход Oleg или конструкцию NOT EXISTS
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question