Roomify / bat_drupal

Booking and Availability Management Tools for Drupal 7 and Drupal 8
33 stars 7 forks source link

Search Availability bottleneck in bat_facets #48

Open borisbsu opened 6 years ago

borisbsu commented 6 years ago

I have noticed, that in bat_facets module you load all BAT types one by one, then in foreach cycle you load units states for each type to check if it matches search criteria: start_date, end_date, valid_states.

In total you execute 4*N database queries where N is the number of BAT types. It's fine when N is small, but in service where N > 1000 or more this is a real bottleneck. E.g. on my dev environment with 900 types the search time > 7 sec. That's terrible and doesn't suit for real booking systems having thousands of properties. In RfA it is even worse - you load roomify_property, then corresponding bat_type, and then unit states. So it's

Have you thought about optimizing search availability algorithm? In my opinion the search should be done on database side, not on Drupal backend.

acrollet commented 6 years ago

@borisbsu thanks for the feedback - as with many open source projects, there's a real funding issue. We'd happily review a pull request or do sponsored development on this issue.

borisbsu commented 6 years ago

@acrollet Ok. I have an idea how to handle search on db side. Hope I will find some time to create a PR for it.