Manual: Useful database queries

Count Active entity generations in summary database

This query counts all entity generations that are not marked as duplicate, have not been marked as EOL yet, have a non-empty title and at least a bit of text or secondary text in their text pile

select count(*)
from entity_generation
inner join document_description
	on entity_generation.entity_generation_id = document_description.entity_generation_id
inner join text_pile
	on entity_generation.text_pile_id = text_pile.text_pile_id
where (
	(NOT entity_generation.marked_duplicate) AND
	entity_generation.confirmed_end_unix_utc is NULL AND
	(document_description.title != '') AND
	(text_pile.text != '' OR text_pile.secondary_text != '')
);