If i use auto generated index values (as primary for later use as foreign reference) there are is this std approach to enter new data: 1.) select query if entry already exists 2a.) if entry exists use returned id as reference or 2b.) insert new entry and query for auto generated id afterwards. In best case i have one select statment. In worst case i have 2 select statments and one insert statment. Is there approach/design i could use to have better worst case? I mean how to solve that problem that auto generated ids are unknown after insert in the first. For apps doing mass inserting this additional selects will cost. On the other side if using client side ids (not auto generated) it comes with disadvantage providing no support for multi client access. In mysql eg there is a method "mysql_insert_id" which shall retrurn autogen id for last insert, this will (maybe) have better perfoemance than run query (multiplied for eg 8 millions inserts). But this is not dbms indepedent and i would like to stay db independent. Any ideas, tx for help.