Information about files in document libraries is strored in the table "AllDocs" of Site's content database. Of course, Microsoft doesn't allow to make queries to SharePoint databases directly. But I can't but agree with inserts and updates are not allowed, but select query in the worst case will make just some locks in database. So I guess that in some cases it's much better to execute select query than powershell script.