I have written an extension to PostgreSQL using OEChem from OpenEye. It creates SQL functions oe_cansmiles, oe_keksmiles, oe_impsmiles, oe_matches, and oe_count_matches. The use of oe_cansmiles, along with indexing features of PostgreSQL, allows the creation of unique, indexed tables of chemical structures for fast lookup. Substructure searches can be performed using oe_matches. The function oe_count_matches can be used to count the number of times each substructure matches, for example to count the number of halogens, hydrogen bond donors, aromatic heteroatoms, etc. in a given structure. I will show examples of two test databases I have created using about 100,000 and 1,000,000 structures from vendor catalogs. Issues of efficiency and speed will be discussed. Finally, further extensions and optimizations of existing extensions will be considered.