Question: I want to execute the following query and put it on a gridview in my asp.net app

```
select *
from INDICATORS, places, places_sales
where places_sales.id = places.id
and 
INDICATORS.line  in (select line from lines)

```

the lines table has like a 28000 records and INDICATORS like 18000

This query is executed in oracle sql developer in 6 seconds, but in my asp.net application (with oracle dataacess as connector) takes like 20 minutes

Is there a way to optimize my query?

Answer: 
There are a couple of things you can do to speed it up.

Firstly, is there a join between places or places\_sales to INDICATORS?

If there is, you shoul add it, you're probably getting a cartesian.

Now, for the optimization piece, try the following:

```
SELECT *
  FROM indicators, places, places_sales
 WHERE places_sales.id = places.id
       AND EXISTS
               (SELECT ''
                  FROM lines l
                 WHERE l.line = indicators.line)

```
My suggestion would be for you to use the GridView with paging

Please see link to understand more on paging of GridView <http://msdn.microsoft.com/en-us/library/5aw1xfh3.aspx>

A nice example can be found here <http://www.dotnetcurry.com/ShowArticle.aspx?ID=339>