CREATE TABLE tnrs ( "Name_number" text, "Name_submitted" text NOT NULL, "Overall_score" text, "Name_matched" text, "Name_matched_rank" text, "Name_score" text, "Name_matched_author" text, "Name_matched_url" text, "Author_matched" text, "Author_score" text, "Family_matched" text, "Family_score" text, "Name_matched_accepted_family" text, "Genus_matched" text, "Genus_score" text, "Specific_epithet_matched" text, "Specific_epithet_score" text, "Infraspecific_rank" text, "Infraspecific_epithet_matched" text, "Infraspecific_epithet_score" text, "Infraspecific_rank_2" text, "Infraspecific_epithet_2_matched" text, "Infraspecific_epithet_2_score" text, "Annotations" text, "Unmatched_terms" text, "Taxonomic_status" text, "Accepted_name" text, "Accepted_name_author" text, "Accepted_name_rank" text, "Accepted_name_url" text, "Accepted_name_species" text, "Accepted_name_family" text, "Selected" text, "Source" text, "Warnings" text, "Accepted_name_lsid" text, CONSTRAINT tnrs_pkey PRIMARY KEY ("Name_submitted" ) ) WITH ( OIDS=FALSE ); COMMENT ON TABLE "TNRS".tnrs IS 'tnrs_accepted_names sorts accepted names first (note that false sorts before true). Accepted names are defined as names that scrub to themselves. Accepted names must be processed before any names that resolve to them, because the entry for the accepted name contains all the ranks parsed out but the resolved name of another entry contains just some ranks and the taxonomic name. Column-based import will do this automatically when the total # of rows is <= the partition_size (because _taxonconcept_set_matched_concept_id()''s accepted taxonconcept is created after the main taxonconcept), but TNRS has more rows than this so sorting is needed to ensure that all the accepted names are processed in the first partitions.'; CREATE INDEX tnrs_accepted_names ON tnrs USING btree ((NOT "Name_submitted" = ("Accepted_name" || COALESCE(' '::text || "Accepted_name_author", ''::text))) , "Name_submitted" ); ALTER TABLE tnrs CLUSTER ON tnrs_accepted_names;