Site Index slow

It looks like I’m asking a similar question here:
http://forum.getkirby.com/t/php-performance-and-kirby/1178/1

One solution I have thought of (but not implemented yet) is to create a single “index” file - containging a big JSON object - that is pared down to the essentials. Kirby would update this index every time a change is made to the panel (using the new hooks feature, excited about this). In my case it would look something like:

$book_index = [];

foreach ($site->pages()->find('writers')->children()->children() as $book) {
	$book_array['url'] = $book->url();
        $book_array['uid'] = $book->uid();
	$book_array['author'] = $book->parent()->title();
	$book_index[] = $book_array;
}

$book_index_file = fopen($_SERVER["DOCUMENT_ROOT"] . '/assets/php/book_index.json', 'a+');
fwrite($book_index_file, serialize($book_index));
fclose($book_index_file);

That way, when I do a search, I don’t need Kirby to fire up all of its engines and parse through all of the subpages. Instead, I’m just looking at a single file, and search results would return only the relevant info: page title, page UID, and page URL.

I imagine that this JSON object (which would not be re-created every time you load the page, only after panel updates) would be easy to build a datatable with.

There may be smarter ways to do this. The Kirby API also has ways of working with databases, but I haven’t looked into it.