I have a database in the following format:
"filename": {
"url": "base64 of Zlib compressed URL to decrease size of file",
"date": "Date added to database",
"size": "Size of file in URL(not always present)"
}
The format is tree-like. for example:
"dirname": {
"url": "base64 of Zlib compressed URL to decrease size of file",
"date": "Date added to database",
[...files and directories in this directory...]
}
can contain more files and directories.
Goal
I'm trying to fuzzy search just the names and return the URL/date(/size) of entries in the database. It currently has 6.5M strings with an average length of about 36 characters. Duplicate names are present in the database.
What I've tried
I figured it would be faster to load the data to RAM first. I have only 8GB on my laptop so i figured to lower the usage i would save the data in list format, where the URL is compressed with Zlib to further decrease RAM usage. The format is something like this:
[["file or directory name", "zlib compressed url", "date", "size if exists"], ...]
which rounds up to around 3GBs currently. Then i splice the list into 20 pieces using an iterator, and passing the iterator to a function and running that in a separate Process.
results = manager.list() # python multiprocessing shared list
#in a loop that splices into n pieces(20 currently):
p = multiprocessing.Process(target=self.slice_search, args=(results, name, iter(self.minimal_data[start:i]), function_to_use, min_score,))
processes.append(p)
p.start()
the "function_to_use" is currently fuzz.QRatio from fuzzywuzzy, "slice_search" is a function that appends the data into a shared list if the result of "function_to_use" on the string is more than a certain threshold.
The results are in stored in a similar format:
[["score", "file or directory name", "zlib compressed url", "date", "size if exists"], ...]
and are sorted after the search is over and saved to a file in human-readable format(the URL's are also decompressed).
Problem
with all of this it still takes about 20-30 seconds to do the search. I truly believe there's a better way, but i don't have the knowledge required to make it happen. My final goal is to get it to work at least faster than 10 seconds. I would appreciate any help or direction you can point me to.