Query posts that are assigned to a global template

Hi all, is it possible to query all post ids in the database that are associated with a specific global template? E.g. via a template ID?

The template data is stored in the wp_postmeta in a serialised object. How could this be determined in a performant way?

Many thanks in advance

You can do a text search in post meta for the template ID
s:6:"global";i:11651; where 11651 is the ID of the saved global row/module/etc

Example:

SELECT post_id as ID, wp_posts.post_title as Title
FROM wp_postmeta
LEFT JOIN wp_posts
ON wp_postmeta.post_id = wp_posts.ID
WHERE
	meta_key = '_fl_builder_data'
AND
	meta_value LIKE '%s:6:"global";i:11651;%' /* 11651 is the template ID */
AND
	wp_posts.post_type = 'fl-builder-template'

thank you very much for your answer.

yes, the text search in the post_meta db is possible, but not a performant database query. in fact, we wanted to avoid querys with like statements.

what we want exactly tin: When a global row is saved/updated, we want to clear the cache for the affected pages. So i want to find out which posts use this template.

BB offers the possibility to clear the cache after saving, but this clears the cache of the whole website. unfortunately, this is not useful for a website with several hundred pages.

Is there another way to do this in the BB?

Many thanks in advance!

The only way BB could do it is with the exact same sort of query, which is why it isnt in the plugin.