When I choose to compact databases for Chrome what exactly is it doing?

I am worried it might be deleting files I care about.

i never select "compact databases."

See this article in the documentation.

https://support.piriform.com/hc/en-us/articles/360047824692-Applications-tab-for-CCleaner-for-Windows#applications-tab-for-ccleaner-for-windows-0-0

Quote
<div class="ipsQuote_contents ipsClearfix" data-gramm="false">
	<p>
		<span style="font-weight: 400;"><strong>Compact Databases</strong> - Some web browsers (notably Mozilla Firefox and Google Chrome) use databases to store bookmarks, history, and other data. When you remove information from these databases, they may still take up room with fragmented space on your hard drive. If you select Compact Database, CCleaner will defragment and trim unused space from these databases.</span>
	</p>
</div>

CCleaner doesn't seem to do it each and every time though.

It's been called a waste of time before (not specifically on this forum) since the database will always grow ("bloat") in size again when the browser is opened. Although it can "supposedly can make a browser run quicker." That functionality it built into Firefox using a command, or at least it was umpteen years ago.

I was wondering this myself and I have had compact databases disabled (unticked) for a while now. For reference, in the past when I had it enabled for Chrome. Chrome was very unstable, much more than now. FF seems to be the most stable but also the slowest.