The performance problems with virtual_libraries() is why I built the plugins
[GUI Plugin] Save Virtual Libraries To Column (GUI) and
[Library Closed Plugin] Save Virtual Libraries To ColumnThey save the virtual libraries containing a book to a tags-like custom column, thus removing the computation required by virtual_libraries() on every book.