Search performance in Preview: Trashing ‘PDFIndex4.sk’ file solved the problem

Posted by Pierre Igot in: Macintosh
November 7th, 2010 • 1:35 pm

On Friday, I wrote about problems I was having with the performance of text-based searches on my system and in particular with searching for long exact phrases in PDF documents in Mac OS X’s Preview.

In my view, searching for an exact phrase should be a pretty fast process, especially when the phrase is fairly long, since the uniqueness of the combination of words in a specific order will make it likely that there is only one occurrence of the search string in the document and it should be fairly easy to find.

And yet on my system, in my regular work environment, I was having to wait for an extraordinarily long time (nearly a minute) to get a result in Preview. I also noted on Friday that I was not able to reproduce the problem in a separate “clean” user environment with no third-party tools installed and running.

This indicated quite clearly to me that there was a problem specific to my regular user environment, but I couldn’t figure out what. A reader wrote to suggest that I take a look at the system log in my console and indeed, when I looked I found that, each time I attempted to do a search for a long exact phrase in Preview, the following messages would appear in the system log:

Nov  7 11:52:01 Mac-Pro-2009 [0x0-0x25025].com.apple.Preview[374]: =================
Nov  7 11:52:01 Mac-Pro-2009 [0x0-0x25025].com.apple.Preview[374]: ERROR: SKIndexTermChars pref returned nil string - using default
Nov  7 11:52:01 Mac-Pro-2009 [0x0-0x25025].com.apple.Preview[374]: (/SourceCache/Preview/Preview-504.1/Sources/PVSearchKitUtils.m:161 PVCleanSKQuery)
Nov  7 11:52:01 Mac-Pro-2009 [0x0-0x25025].com.apple.Preview[374]: =================

But this didn’t get me anywhere nearer to solving the problem. I searched for some of the keywords in the messages above on-line with Google, and only got a few unrelated results.

I also tried trashing the “com.apple.Preview.plist” preference file in my home library and relaunching Preview, but it didn’t help either.

Today, I decided to get more serious about it and so I logged out and logged back in holding the Shift key down, which prevents all login items from launching automatically. (Sadly, it also prevents the Finder from opening the Finder windows that were left open when you last quit the Finder, which is a bit of an annoyance.)

After this, I launched Preview by itself, opened the same PDF file and tried the same exact phrase search as before. Again, the search took nearly 40 seconds to produce the expected result—whereas in a separate “clean” user environment, I would get the result in a couple of seconds. So clearly none of my third-party tools was the culprit.

I figured that I should try trashing all the caches in my home library’s “Caches” folder, even though they all seemed to be unrelated to the Preview application. But before doing that, I decided to do a backup of the caches, just in case. The “Caches” folder weighed nearly 5 GB, so the copying process took a while.

During that time, I explored other corners of my home library folder and found that there was a folder called “Preview” inside the “Application Support” folder. Until today, I wasn’t aware of the existence of that folder.

The folder contained a single file called “PDFIndex4.sk” that weighed approximately 90 MB. I trashed the file, relaunched Preview, tried the exact same search for an exact phrase in the same PDF file and… I got the result in 2 seconds!

So that “PDFIndex4.sk” file was clearly the culprit. Preview recreated a new one with the same name in the same location, and it now weighs only 295 KB.

Out of curiosity, I opened the 90 MB “PDFIndex4.sk” file that I had trashed with BBEdit. BBEdit shows a mix of garbage and lots of natural language keywords. (I didn’t go very far in my exploration, because BBEdit becomes very sluggish when browsing a 90 MB file.)

A quick search for “PDFIndex4.sk” in the Apple Discussions forums finds a few mentions of the file and of trashing it as a way to solve various problems in Preview.

It seems strange to me that such an index file would be stored under “Application Support” and not under “Caches,” but I don’t know in full what the logic is behind the whole organization of the library folder.

All I know is that I am glad that fixing this problem turned out to be a fairly simple and seemingly harmless operation. I just wish I had found out about it earlier, because I have been patiently waiting for the results of searches for exact phrases in PDF files for several weeks now. I am delighted that they are instantaneous again, and I’ll be sure to remember that particular trouble-shooting tip if I ever encounter the problem again.


One Response to “Search performance in Preview: Trashing ‘PDFIndex4.sk’ file solved the problem”

  1. Slow Spotlight searches? « The Matrix Data Bank says:

    […] =================If so, take a look in your ~/library/Application Support/Preview folder.Piere Igot, of Betalogue, asked about this a few days ago… And was able to trace his issue down to this file.My system is showing this file at about […]