I'm importing some Excel spreadsheets via ETL into a relational database. The problem is that for me to be able to perform the relationship of the tables, I am using queries for the insertion of the foreign keys. But as the bank grows, these queries are taking an uncanny time. Is there any way to perform an UPDATE only on the last records that were included? For example:
UPDATE estrutura q
SET q.id_horizonte = (SELECT h.id_horizonte FROM horizonte h
WHERE q.observacao = h.observacao AND q.nome_horizonte = h.nome_horizonte AND q.amostra_codigo = h.amostra_codigo)
LIMIT 50
It is not working that way, but my question is just this: is there any way for this UPDATE not to be applied to all records in the table and only in the last 50 included? This would greatly help with query performance.