UPDATE: I got it working and it’s still fast even with 340k records! I had to learn some PHP in the process, which wasn’t as bad as I thought it would be. (I know a bit of python and a bit of JavaScript, but PHP has always been intimidating to me. I just hear back-end and run.) I ended up creating a custom table using MIGX and ExtraBuilder and did the query with XPDO. I wanted to thank you all for your responses here and the resources you have provided online, which really helped me to figure this out! Also wanted to list online sources, in case it might help another newb like me.
Here is my much faster demo:
https://historysearch.cclibraries.com/?ref=689916
SOURCES:
What helped me to set up MIGX custom data tables: (Thank you @halftrainedharry and @robcarey )
What helped me to understand the fundamentals, like snippets, placeholders and XPDO: (Thank you @bobray )
MODX: The Official Guide: Ray, Bob, Hickey, Michael, Thrash, Ryan: 9780983619406: Amazon.com: Books &
https://bobsguides.com/
What helped me with the pagination of my snippet: (Thank you @markh )
Using PDOTools for pagination helped a lot, and this documentation really helped:
Other sources that helped:
https://docs.modx.com/3.x/en/extending-modx/modx-class/reference/modx.getchunk
https://docs.modx.com/3.x/en/extending-modx/xpdo/class-reference/xpdo/xpdo.getcount
https://docs.modx.com/3.x/en/extending-modx/xpdo/class-reference/xpdoquery
MIGX/core/components/migx/configs/migxconfigs.config.inc.php at b14c5abdb5503095b18975b391ef2615811c63aa · Bruno17/MIGX · GitHub (Refrerenced the query example starting at line 48.)
AdvSearch/core/components/advsearch/elements/snippets/advsearch.snippet.php at e0850067604da1c70052d175e6ca89647e578ede · Coroico/AdvSearch · GitHub (Looked at how to sanitize input with PHP.)
Thanks again!