greghoch Posted March 22, 2013 Share Posted March 22, 2013 Hi, my workflow shows results from a large database and caches the relevant information from this database so that the information is easier and faster to retrieve (I have a search index and separate files for each database entry). The problem is that I don't know when to run the caching function. It slows everything down. Here is what I tried: 1) run it in the background using subprocess or from the shell (still seems to stop alfred from showing my results) 2) run it after printing the feedback (Alfred seems to wait until the end of the script before showing any results 3) run it when len(query) == 0 and only show results when len(query) > 2. I thought that is a good idea but now I would like to show the results from the last search before the user has entered at least three characters. And ideas? Link to comment
jdfwarrior Posted March 22, 2013 Share Posted March 22, 2013 Hi, my workflow shows results from a large database and caches the relevant information from this database so that the information is easier and faster to retrieve (I have a search index and separate files for each database entry). The problem is that I don't know when to run the caching function. It slows everything down. Here is what I tried: 1) run it in the background using subprocess or from the shell (still seems to stop alfred from showing my results) 2) run it after printing the feedback (Alfred seems to wait until the end of the script before showing any results 3) run it when len(query) == 0 and only show results when len(query) > 2. I thought that is a good idea but now I would like to show the results from the last search before the user has entered at least three characters. And ideas? Is this a remote, local, or a database on the local network? Most databases provide pretty high performance unless you are trying to return a HUGE set of data. Could your query be modified any to make it more accurate and therefore reduce the result set? Link to comment
ctwise Posted March 22, 2013 Share Posted March 22, 2013 Hi, my workflow shows results from a large database and caches the relevant information from this database so that the information is easier and faster to retrieve (I have a search index and separate files for each database entry). The problem is that I don't know when to run the caching function. It slows everything down. Here is what I tried: 1) run it in the background using subprocess or from the shell (still seems to stop alfred from showing my results) 2) run it after printing the feedback (Alfred seems to wait until the end of the script before showing any results 3) run it when len(query) == 0 and only show results when len(query) > 2. I thought that is a good idea but now I would like to show the results from the last search before the user has entered at least three characters. And ideas? The Objective-C handler for running shells is aggressive in reaping children. I haven't found a reliable mechanism for kicking out sub-shells that Alfred will ignore. If your data source is super slow AND is query-specific, you're best keying off of something, e.g., tacking on a period at the end of the query and waiting to see the trailing period. If your data source is super slow and ISN'T query-specific, check for the cache at the top of the script, use the cache if you find it, generate it if you don't. It'll be slow the first time and fast the rest of the time. Link to comment
greghoch Posted March 22, 2013 Author Share Posted March 22, 2013 Thanks for the tips. I will go for caching if the database has changed and only update the cache for modified items. That seems like a good solution. In general, using the database directly is fast and only takes about a second. But of the great things about Alfred is to get results quickly and the second was too much for me... just disturbs the workflow. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now