What is the best way to write a cron that deletes a very large number old nodes and comments? I am writing a module the preferably implements a cron job, and possibly a queue, to run sql queries to delete old nodes and their comment. Approximately 20 Million nodes, and about 40 mil comments. I want to run pure mysql queries and bypass the drupal api (as much as I can), for performance reasons. I have already developed the relevant queries and would like to know what would be the best way I could implement this so it does not user Drupal api? This is on drupal 7 by the way.
I would never think running raw SQL queries is a good idea because that can mess up a lot of things such as site maps, search index, caches, etc. 

it's just a node_delete() and shouldn't be much slower that deleting a bunch of rows in multiple tables. 

Whatever that is, you will need to implement hook_cron and retrive nodes to be deleted from 'node' table. 

If you run a node_delete you won't need to delete comments. 

You can limit the number of nodes to delete in a single cron run using LIMIT  keyword. 

Update:
You might want to have a look at Delete All module. and there is a patch (which I submitted) to use the Batch API to do the job. From my experience I know even the Batch API can't handle it (or you have to wait several days with the browser open).

You can just use hook_cron to load a bunch of nodes to be deleted, and then delete them in your preferred way (node_delete or raw SQL). Let the cron finish, and in the next run, it will grab some other nodes. 
Just get your nodes from node table and limit it with a LIMIT.