Kundan Kumar
Kundan Kumar

Reputation: 2002

Avoid running the same query multiple times that takes lot of time

I am running a complex database query that takes enough time.

First I am unloading the results into a file and then I am running this query again to delete all those entries. This again takes lots of time.

Is there a better way so that I can save time here and fulfill both the purposes.

I am new to databases..dont have idea whether there is a way.

Thanks !!!

Upvotes: 1

Views: 445

Answers (1)

Michał Niklas
Michał Niklas

Reputation: 54312

You must find bottleneck in your query or process: is it SQL query or saving data to slow media?

If it is SQL query then try to find what part of this query takes most of the time and for example add some indexes to make it faster. Have a look at similar question: Tweak Informix query . Remember that SET EXPLAIN is your friend. Also remember to UPDATE STATISTICS after you change a lot of data in database.

Why do you unload the results into a file? Do you analyze those results with different tools? If so then maybe there is a way to do it more efficiently in SQL?

Upvotes: 1

Related Questions