Bulk delete via Direct Database Query

I am wondering if I can take advantage of Direct Database Query to remove multiple (thousands) of records.

My query:

DELETE FROM abc
WHERE id IN (?);

This works if I specify the id values by hand, but when using an argument there I run into an SQL error. Even when I transform an array of ids to a text like '1, 2, 3', the function fails with such an error
SQLSTATE[22P02]: Invalid text representation

1. Is this a better path for deleting thousands of records instead of looping?
2. What can be done to make it run?

Thanks.

5 replies