Get data and stats about files in document libraries in SharePoint site from SQL Server
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.
Now I prepare for migration from SharePoint 2010 to SharePoint 2016. There is a lot of customizations in SharePoint 2010, as with server code (webparts, timer jobs, event recievers), so and customization with JavaScript.
Mostly JavaScript files for custom list forms or pages are stored in special document library. To realize the size of main site collection, it's size about 120Gb. Now I take part in audit of portal. With server code solutions is rather easy –I looked at the list of WSP files in the central administration. Especially, all of WSP-solutions were installed by me. But to find all the JavaScript files in all SPWebs is much more difficult task. Most of them were made by SPWeb administrators, I don't even know about some of them.
To get the list of JavaScript files that are stored in document libraries, you can use select query like this:
--Request to find where JS file used in SharePoint use WSS_Content_Portal go SELECT t2.Title, t1.Id ,t1.SiteId ,t1.DirName ,t1.LeafName ,t1.WebId ,t1.ListId ,t1.DoclibRowId ,t1.Type ,t1.Size FROM dbo.AllDocs t1 INNER JOIN dbo.AllWebs t2 on t1.WebId = t2.Id WHERE t1.LeafName like '%.js' AND t1.DeleteTransactionId = 0x
In my database this query was executed about 5 seconds. Of course, there could be some locks in database, but it could take at least 5 hours for similar result via PowerShell.