Query in SolrNet very slow, but the same is blazing fast from Solr Admin UI

226 views
Skip to first unread message

Mihir Mehta

unread,
Sep 24, 2015, 8:36:24 AM9/24/15
to SolrNet
I am a newbie to Solr. I've indexed 29 Million records from a single database table into solr thru the Solr Admin UI.
Only 1 column is indexed and that is the column I am searching on.

This is my code:

static void Main(string[] args)
        {
            Startup.Init<Address>(<SolrURL>);
            QuerySolr();
        }
 
private static void QuerySolr()
        {
            var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Address>>();
            SolrQueryResults<Address> lstAddresses = solr.Query("Postcode:KT111TF"); 
lstAddresses = solr.Query("Postcode:KT138DP");             lstAddresses = solr.Query("Postcode:SL61JN");             lstAddresses = solr.Query("Postcode:EC1Y0RN");         }

Each of the highlighted takes a lot of time to execute......generally 1-10 seconds. The lstAddresses.QTime is also in the same range for each query.
But the same query runs withing 150-250 ms from the Admin UI. Am I doing anything wrong here?


Mauricio Scheffer

unread,
Sep 24, 2015, 8:39:05 AM9/24/15
to sol...@googlegroups.com
Check out https://github.com/mausch/SolrNet/blob/master/Documentation/Querying.md#pagination .
I admit that not defining pagination is absolutely not intuitive and I consider it deprecated, eventually I'll make the breaking change.
Also this issue is probably common enough that it's worth an entry in the FAQ ( https://github.com/mausch/SolrNet/blob/master/Documentation/FAQ.md )...

Cheers



--
Mauricio

--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to solrnet+u...@googlegroups.com.
To post to this group, send email to sol...@googlegroups.com.
Visit this group at http://groups.google.com/group/solrnet.
For more options, visit https://groups.google.com/d/optout.

Mihir Mehta

unread,
Sep 24, 2015, 11:09:40 AM9/24/15
to SolrNet
Mauricio,

           Thanks for your prompt reply. I know as a matter of fact that in no case will I have more than 100 results. I will still check the pagination thing and will post my findings here tomorrow morning.

But The second link FAQ.md  - didn't find any clues there.

I also tried doing this :

        Uri uri = new Uri(<SolrURL>);

        WebRequest request = HttpWebRequest.Create(uri);
        request.Method = WebRequestMethods.Http.Get;
        WebResponse response = request.GetResponse();
        StreamReader reader = new StreamReader(response.GetResponseStream());
        string jsonResponse = reader.ReadToEnd();
        response.Close();

This too is extremely fast. As fast as from the Solr Admin UI. So I have this feeling that some thing is not right about my solrnet code.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Mauricio Scheffer

unread,
Sep 24, 2015, 12:05:46 PM9/24/15
to sol...@googlegroups.com
About the FAQ: I meant we should *add* this to the FAQ.
About the slow query: remember that you can always check the Solr log to see exactly what Solr is receiving from the .NET code, this is often useful to diagnose issues.

Cheers

--
Mauricio

Mihir Mehta

unread,
Sep 25, 2015, 3:03:15 AM9/25/15
to SolrNet
Mauricio,

     Thanks a lot. That Pagination thing really worked. Because I know that for a given post code I'll get a max of 100 records in the result - I set :
    
QueryOptions opts = new QueryOptions();
opts.Rows = 100;

But I don't understand how this exactly works. If you don't specify the rows in the Solr Admin Site - it takes the default as 10. If you do
then - that is the max number of records it'll retrieve. But if we don't specify the rows parameter from SolrNet - then it takes the maximum
possible? Is that the case. Can you explain to me in a little detail how exactly this works.

Even though the Postcode columns is indexed and there's a KeywordTokenizer applied on its datatype. From the index Solr would know the
number of records that exist - say 50 for a particular Postcode - will it then still go and search the full data? Am a bit confused.

Thank you
records

Mauricio Scheffer

unread,
Sep 28, 2015, 5:12:07 AM9/28/15
to SolrNet
As explained in the docs, in Solr you can't retrieve all your documents in single query. However, by default SolrNet will try to retrieve a large amount of documents, trying to mimic the behavior of a RDBMS without a TOP clause. It's not recommended to rely on this behavior.

Cheers
Reply all
Reply to author
Forward
0 new messages