Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Very slow query
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  24 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
marcandre  
View profile  
 More options Sep 10 2012, 8:50 am
From: marcandre <malegr...@gmail.com>
Date: Mon, 10 Sep 2012 05:50:17 -0700 (PDT)
Local: Mon, Sep 10 2012 8:50 am
Subject: Very slow query

Good afternoon,

I'am using MongoDB with 350 000 documents and php. The problem is the php
reads documents very slowly .

When I'm updating documents I drop the database and I insert the documents
: during this processus the inserts are very long .

I don't understand, I putted indexes .

I show you a piece of my php code when I updating documents :

$cnx_mongo = new Mongo("127.0.0.1", array("persist" => "x"));

 $db = $cnx_mongo->my_database;
 $ma_collection = $db->my_collection;

 $response = $ma_collection->drop();
 $response = $db->drop();

 $db = $cnx_mongo->my_database;
 $ma_collection = $db->my_collection;

 ///I Import data from a database Postgres

 ///I put index in a fiel named tags
 $ma_collection->ensureIndex("tags");

This is the code when php reads documents :

///Research of documents who containts key words
$cnx_mongo = new Mongo("127.0.0.1", array("persist" => "x"));
$db = $cnx_mongo->my_database;
$ma_collection = $db->my_collection;

 //Get back keywords researching by tags fields
 $who = array();
 if(count($ArrayWord) > 1) {
  $tmp = array();
  foreach ($ArrayWord as $q) {
   $tmp[] = new MongoRegex( "/". strtolower($q) ."/" );
  }

  $who['tags'] = array('$all' => $tmp);

 }else{
  $who['tags'] = new MongoRegex( "/". strtolower($mot) ."/" );
 }

 $cursor = $ma_collection->find($who)->limit(30)->skip(60);

 $cursor->timeout(1000);

 print($cursor->count()); // I display the number of documents

 foreach($cursor as $obj){
  ///I display the results of document  
 }

The tags field containts array keywords .

What should I do to resolve this problem ?

I checked the RAM (6 Go of physical RAM and 4 Go of available memory) .

How can I check the cause of this slow reads and inserts ?

I there is something to configure in mongodb ?

Best regards .


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gianfranco  
View profile  
 More options Sep 10 2012, 9:43 am
From: Gianfranco <gianfra...@10gen.com>
Date: Mon, 10 Sep 2012 06:43:55 -0700 (PDT)
Local: Mon, Sep 10 2012 9:43 am
Subject: Re: Very slow query

Hi,

First of all there is no need to drop the collection if you're going to
drop the database containing that collection.

You can set profiling on, to record the queries which take a long time (by
default more than 100ms)
http://www.mongodb.org/display/DOCS/Database+Profiler

Is this a batch script which loads data from PostgreSQL to MongoDB?

Can you explain again what are you trying to do?
And which queries are slow find() and/or insert() ?

Gianfranco


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
marcandre  
View profile  
 More options Sep 10 2012, 10:16 am
From: marcandre <malegr...@gmail.com>
Date: Mon, 10 Sep 2012 07:16:51 -0700 (PDT)
Local: Mon, Sep 10 2012 10:16 am
Subject: Re: Very slow query

Yes it is the batch script witch loads data from PostgresSQL to MongoDB :

$cnx_mongo = new Mongo("127.0.0.1", array("persist" => "x"));

$db = $cnx_mongo->my_database;
$ma_collection = $db->my_collection;

 $response = $ma_collection->drop();
 $response = $db->drop();

 $db = $cnx_mongo->my_database;
 $ma_collection = $db->my_collection;

 $SQL = "select id_marchand, titre_prod, img_prod_petit, img_prod_zoom,
produit.prix_ht, produit.prix_ttc, ref_constr, marque,categorie,
sous_categorie, prix_max, prix_min, nb_offres, max_dispo, min_dispo,
id_offre, id_prod from product";

 $rs = $cnx->query($SQL);

 $tab_produit = NULL;
 if ($rs != FALSE) {
   $tab_produit = $rs->fetchAll();
 }
 $tab = array();
 $num_tab = 0;

 $num_ligne = 0;

 $tags = array();

 ///Loading data from Postgres to MongoDB
 for($ii = 0; $ii < count($tab_produit); $ii++){
  $id_prod = $tab_produit[$ii]['id_prod'];
  $titre_prod = utf8_decode($tab_produit[$ii]['titre_prod']);
  $img_prod_petit = $tab_produit[$ii]['img_prod_petit'];
  $img_prod_zoom = $tab_produit[$ii]['img_prod_zoom'];
  $ref_constr = $tab_produit[$ii]['ref_constr'];
  $marque = $tab_produit[$ii]['marque'];
  $categorie = utf8_decode($tab_produit[$ii]['categorie']);

  $sous_categorie = utf8_decode($tab_produit[$ii]['sous_categorie']);
  $prix_max = $tab_produit[$ii]['prix_max'];
  $prix_min = $tab_produit[$ii]['prix_min'];
  $nb_offres = $tab_produit[$ii]['nb_offres'];
  $max_dispo = $tab_produit[$ii]['max_dispo'];
  $min_dispo = $tab_produit[$ii]['min_dispo'];
  $id_offre = $tab_produit[$ii]['id_offre'];
  $id_assoc = $tab_produit[$ii]['id_assoc'];

  $titre_prod = utf8_encode(str_replace('"','&quot;',str_replace("É","E",
strtolower($titre_prod))));
  $titre_recherche = $titre_prod . " " . strtolower($ref_constr);

  $tags = split(" ",$titre_recherche);

  //I insert document in Collection of MongoDB
  $obj = array( "id_prod" => "$id_prod", "titre_prod" => "$titre_prod",
"img_prod_petit" => "$img_prod_petit", "img_prod_zoom" => "$img_prod_zoom",
"ref_constr" => "$ref_constr", "marque" => "$marque", "categorie" =>
"$categorie", "sous_categorie" => "$sous_categorie", "prix_max" =>
"$prix_max", "prix_min" => "$prix_min", "nb_offres" => "$nb_offres",
"max_dispo" => "$max_dispo", "min_dispo" => "$min_dispo", "id_offre" =>
"$id_offre", "titre_recherche" => "$titre_recherche", "id_assoc" =>
"$id_assoc", "tags" => $tags  );
  $ma_collection->insert($obj);
 }

 $ma_collection->ensureIndex("tags");

 unset($ma_collection,$db,$cnx_mongo);

 $cnx = NULL;
 unset($cnx);

Thank you for your response .

Le lundi 10 septembre 2012 15:43:55 UTC+2, Gianfranco a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gianfranco  
View profile  
 More options Sep 10 2012, 10:42 am
From: Gianfranco <gianfra...@10gen.com>
Date: Mon, 10 Sep 2012 07:42:35 -0700 (PDT)
Local: Mon, Sep 10 2012 10:42 am
Subject: Re: Very slow query

As you did correctly, if this is not a live production database, you
can ensureIndex() after you finish the batch.
Because if there's an index, the database needs to update the index every
time there is new document inserted.

Is it possible, and i'm just wondering here, that PostgreSQL is one of the
causes of the batch being slow?
If not do you have any more information on why is not?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
marcandre  
View profile  
 More options Sep 10 2012, 11:07 am
From: marcandre <malegr...@gmail.com>
Date: Mon, 10 Sep 2012 08:07:30 -0700 (PDT)
Local: Mon, Sep 10 2012 11:07 am
Subject: Re: Very slow query

I don't think that Postgres causes the bach being slow, because when I use
MongoDB as a  reseach engin  to research documents by keywords ,

my reseach engin is very slow or ends with an error of timeout : *Fatal
error: Uncaught exception 'MongoCursorTimeoutException' with message
'cursor timed out (timeout: 30000, time left: 0:0, status: 0)'*  .

This my code for research douments :

$cnx_mongo = new Mongo("127.0.0.1", array("persist" => "x"));
$db = $cnx_mongo->my_database;
$ma_collection = $db->my_collection;

$who = array();
 if(count($ArrayWord) > 1) {
  $tmp = array();
  foreach ($ArrayWord as $q) {
   $tmp[] = new MongoRegex( "/". strtolower($q) ."/" );
  }
  $who['tags'] = array('$all' => $tmp);
 }else{
  $who['tags'] = new MongoRegex( "/". strtolower($mot) ."/" );
 }

$cursor = $ma_collection->find($who)->limit(30)->skip(($off_set - 1)*30);

$cursor->timeout(1000);

print($cursor->count());

foreach($cursor as $obj){

$id_prod = $obj["id_prod"];
$ref_constr = $obj["ref_constr"];
$img_prod = $obj["img_prod_petit"];
$zoom = $obj["img_prod_zoom"];
$titre = utf8_decode($obj["titre_prod"]);

$prix_max = $obj["prix_max"];
$prix_min = $obj["prix_min"];
$nb_offres = $obj["nb_offres"];
$max_dispo = $obj["max_dispo"];
$min_dispo = $obj["min_dispo"];
$id_assoc = $obj["id_assoc"];

}

Le lundi 10 septembre 2012 16:42:35 UTC+2, Gianfranco a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gianfranco  
View profile  
 More options Sep 10 2012, 11:31 am
From: Gianfranco <gianfra...@10gen.com>
Date: Mon, 10 Sep 2012 08:31:40 -0700 (PDT)
Local: Mon, Sep 10 2012 11:31 am
Subject: Re: Very slow query

If you run explain() on the cursor you can see why is taking that long.

var_dump($cursor->explain());

Do that on one and see if it's using an index (BtreeCursor)

Another problem could be that you are limiting the find() results to 30 and
then doing a skip.
This is not every efficient, and I don't understand from your code exactly
why are you doing that.

You can also try to increase the timeout of the cursor and try if that helps


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
marcandre  
View profile  
 More options Sep 10 2012, 11:48 am
From: marcandre <malegr...@gmail.com>
Date: Mon, 10 Sep 2012 08:48:11 -0700 (PDT)
Local: Mon, Sep 10 2012 11:48 am
Subject: Re: Very slow query

I get this reponse when I call var_dump($cursor->explain());  :

array(15) { ["cursor"]=> string(11) "BasicCursor" ["isMultiKey"]=>
bool(false) ["n"]=> int(30) ["nscannedObjects"]=> int(1148) ["nscanned"]=>
int(1148) ["nscannedObjectsAllPlans"]=> int(1148) ["nscannedAllPlans"]=>
int(1148) ["scanAndOrder"]=> bool(false) ["indexOnly"]=> bool(false)
["nYields"]=> int(0) ["nChunkSkips"]=> int(0) ["millis"]=> int(2)
["indexBounds"]=> array(0) { } ["allPlans"]=> array(1) { [0]=> array(5) {
["cursor"]=> string(11) "BasicCursor" ["n"]=> int(30) ["nscannedObjects"]=>
int(1148) ["nscanned"]=> int(1148) ["indexBounds"]=> array(0) { } } }
["server"]=> string(12) "host:27017" }

I am limiting the find to avoid display every documents in the same page  .

Le lundi 10 septembre 2012 17:31:40 UTC+2, Gianfranco a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
gelin yan  
View profile  
 More options Sep 10 2012, 11:52 am
From: gelin yan <gelin....@gmail.com>
Date: Mon, 10 Sep 2012 08:52:28 -0700 (PDT)
Local: Mon, Sep 10 2012 11:52 am
Subject: Re: Very slow query

在 2012年9月10日星期一UTC+8下午11时48分11秒,marcandre写道:

Hi
     "BasicCursor" implies your index didn't work for your query.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gianfranco  
View profile  
 More options Sep 10 2012, 12:01 pm
From: Gianfranco <gianfra...@10gen.com>
Date: Mon, 10 Sep 2012 09:01:33 -0700 (PDT)
Local: Mon, Sep 10 2012 12:01 pm
Subject: Re: Very slow query

Yes, as Gelin said.
That query is not using an index, that's why is taking longer, going
through the entire collection.

Make sure you ensureIndex() on the correct fields.
Then try doing an explain again to check if it worked


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
marcandre  
View profile  
 More options Sep 10 2012, 3:10 pm
From: marcandre <malegr...@gmail.com>
Date: Mon, 10 Sep 2012 12:10:37 -0700 (PDT)
Local: Mon, Sep 10 2012 3:10 pm
Subject: Re: Very slow query

Thank you very much for these informations,

But, how can I get a BtreeCursor  with ensureIndex() function ?
Whitch arguments can I put in this function, I know that I have to give the
field name in the first argument .

Le lundi 10 septembre 2012 18:01:33 UTC+2, Gianfranco a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Millman  
View profile  
 More options Sep 10 2012, 3:14 pm
From: Sam Millman <sam.mill...@gmail.com>
Date: Mon, 10 Sep 2012 20:14:02 +0100
Local: Mon, Sep 10 2012 3:14 pm
Subject: Re: [mongodb-user] Re: Very slow query

Non-prefixed regexes do not use indexes would be one of your problems:

$who = array();
 if(count($ArrayWord) > 1) {
  $tmp = array();
  foreach ($ArrayWord as $q) {
   $tmp[] = new MongoRegex( "/". strtolower($q) ."/" );
  }
  $who['tags'] = array('$all' => $tmp);
 }else{
  $who['tags'] = new MongoRegex( "/". strtolower($mot) ."/" );
 }

What exactly are you trying to do here?

On 10 September 2012 20:10, marcandre <malegr...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
marcandre  
View profile  
 More options Sep 10 2012, 3:44 pm
From: marcandre <malegr...@gmail.com>
Date: Mon, 10 Sep 2012 12:44:33 -0700 (PDT)
Local: Mon, Sep 10 2012 3:44 pm
Subject: Re: [mongodb-user] Re: Very slow query

In this code I am trying is to research only documents that have all
keywords asked by the client,

For example a user who is looking for documents, when he types "windows
2008 Server R2 Datacenter" or "win 2008 Server R Data"  the research engin
have to
display documents that contains the following keywords : array(0 =>
windows, 2008, Server, R2, Datacenter)  contained in the "tags" field (It
is an array)

Le lundi 10 septembre 2012 21:14:11 UTC+2, Sammaye a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Millman  
View profile  
 More options Sep 10 2012, 3:50 pm
From: Sam Millman <sam.mill...@gmail.com>
Date: Mon, 10 Sep 2012 20:50:05 +0100
Local: Mon, Sep 10 2012 3:50 pm
Subject: Re: [mongodb-user] Re: Very slow query

If it is an array of words then you don't need the regex, try taking that
out.

On 10 September 2012 20:44, marcandre <malegr...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Millman  
View profile  
 More options Sep 10 2012, 3:52 pm
From: Sam Millman <sam.mill...@gmail.com>
Date: Mon, 10 Sep 2012 20:52:10 +0100
Local: Mon, Sep 10 2012 3:52 pm
Subject: Re: [mongodb-user] Re: Very slow query

Ok my last message was written a bit quickly.

Basically I understand what your trying to do, essentially an FTS. Problem
is the infixing on your fields is 2 characters min so "win 2008 Server R
Data" won't match without regex. I strongely suggest you either deal with
out regex or you split up your words further, but then they could lose
their meaning and return superflious amount of documents.

On 10 September 2012 20:50, Sam Millman <sam.mill...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Millman  
View profile  
 More options Sep 10 2012, 4:03 pm
From: Sam Millman <sam.mill...@gmail.com>
Date: Mon, 10 Sep 2012 21:03:26 +0100
Local: Mon, Sep 10 2012 4:03 pm
Subject: Re: [mongodb-user] Re: Very slow query

Though thinking twice here, you can prefix since win would match windows
with /^win/ and r would match r2 with /^r/. That might work.

On 10 September 2012 20:52, Sam Millman <sam.mill...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
marcandre  
View profile  
 More options Sep 11 2012, 3:45 am
From: marcandre <malegr...@gmail.com>
Date: Tue, 11 Sep 2012 00:45:42 -0700 (PDT)
Local: Tues, Sep 11 2012 3:45 am
Subject: Re: [mongodb-user] Re: Very slow query

Hellow everybody ,

When I update my code I get with explain cursor :

array(16) { ["cursor"]=> string(24) "BtreeCursor tags_1 multi"
["isMultiKey"]=> bool(true) ["n"]=> int(30) ["nscannedObjects"]=> int(330)
["nscanned"]=> int(330) ["nscannedObjectsAllPlans"]=> int(330)
["nscannedAllPlans"]=> int(330) ["scanAndOrder"]=> bool(false)
["indexOnly"]=> bool(false) ["nYields"]=> int(0) ["nChunkSkips"]=> int(0)
["millis"]=> int(8) ["indexBounds"]=> array(1) { ["tags"]=> array(2) {
[0]=> array(2) { [0]=> string(7) "windows" [1]=> string(7) "windowt" }
[1]=> array(2) { [0]=> object(MongoRegex)#7 (2) { ["regex"]=> string(8)
"^windows" ["flags"]=> string(0) "" } [1]=> object(MongoRegex)#8 (2) {
["regex"]=> string(8) "^windows" ["flags"]=> string(0) "" } } } }
["allPlans"]=> array(1) { [0]=> array(5) { ["cursor"]=> string(24)
"BtreeCursor tags_1 multi" ["n"]=> int(30) ["nscannedObjects"]=> int(330)
["nscanned"]=> int(330) ["indexBounds"]=> array(1) { ["tags"]=> array(2) {
[0]=> array(2) { [0]=> string(7) "windows" [1]=> string(7) "windowt" }
[1]=> array(2) { [0]=> object(MongoRegex)#9 (2) { ["regex"]=> string(8)
"^windows" ["flags"]=> string(0) "" } [1]=> object(MongoRegex)#10 (2) {
["regex"]=> string(8) "^windows" ["flags"]=> string(0) "" } } } } } }
["oldPlan"]=> array(2) { ["cursor"]=> string(24) "BtreeCursor tags_1 multi"
["indexBounds"]=> array(1) { ["tags"]=> array(2) { [0]=> array(2) { [0]=>
string(7) "windows" [1]=> string(7) "windowt" } [1]=> array(2) { [0]=>
object(MongoRegex)#11 (2) { ["regex"]=> string(8) "^windows" ["flags"]=>
string(0) "" } [1]=> object(MongoRegex)#12 (2) { ["regex"]=> string(8)
"^windows" ["flags"]=> string(0) "" } } } } } ["server"]=> string(12)
"host:27017" }

For this moment my code look for one key word . I use research by keyword
prefix like for example  /^windows/ . But when I type the word (windows for
example), the first time the web page is very slow (It take 1 or 2
minutes to display results), and the second time the web page responses
very quikly (less than 1 second) .

Thank you very much

Le lundi 10 septembre 2012 22:03:35 UTC+2, Sammaye a écrit :

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
marcandre  
View profile  
 More options Sep 11 2012, 10:18 am
From: marcandre <malegr...@gmail.com>
Date: Tue, 11 Sep 2012 07:18:05 -0700 (PDT)
Local: Tues, Sep 11 2012 10:18 am
Subject: Re: [mongodb-user] Re: Very slow query

Hellow,  

Is there someone to help me to resolve the slowness problem of my code with
MongoDB ?

Thank you.

Le mardi 11 septembre 2012 09:45:42 UTC+2, marcandre a écrit :

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Millman  
View profile  
 More options Sep 11 2012, 10:29 am
From: Sam Millman <sam.mill...@gmail.com>
Date: Tue, 11 Sep 2012 15:29:45 +0100
Local: Tues, Sep 11 2012 10:29 am
Subject: Re: [mongodb-user] Re: Very slow query

Can you show us a formatted explain from console using this command? It's a
bit hard to read that one.

From what I can see it is using the index now so it might not be the query
that is the problem since you nsscanned is also quite small.

Also try running this same query in console now without the explain and see
if it is slow there.

On 11 September 2012 15:18, marcandre <malegr...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
marcandre  
View profile  
 More options Sep 11 2012, 10:57 am
From: marcandre <malegr...@gmail.com>
Date: Tue, 11 Sep 2012 07:57:40 -0700 (PDT)
Local: Tues, Sep 11 2012 10:57 am
Subject: Re: [mongodb-user] Re: Very slow query

Ok , this is the my formatted explain when I execute the same query with
"windows" keyword in my php page :

array(16) {
 ["cursor"]=> string(24) "BtreeCursor tags_1 multi"
 ["isMultiKey"]=> bool(true)
 ["n"]=> int(30)
 ["nscannedObjects"]=> int(30)
 ["nscanned"]=> int(30)
 ["nscannedObjectsAllPlans"]=> int(30)
 ["nscannedAllPlans"]=> int(30)
 ["scanAndOrder"]=> bool(false)
 ["indexOnly"]=> bool(false)
 ["nYields"]=> int(0)
 ["nChunkSkips"]=> int(0)
 ["millis"]=> int(0)
 ["indexBounds"]=> array(1) {
  ["tags"]=> array(2) {
   [0]=> array(2) {
    [0]=> string(7) "windows"
    [1]=> string(7) "windowt"
   }
   [1]=> array(2) {
    [0]=> object(MongoRegex)#6 (2) {
     ["regex"]=> string(8) "^windows"
     ["flags"]=> string(0) ""
    }
    [1]=> object(MongoRegex)#7 (2) {
     ["regex"]=> string(8) "^windows"
     ["flags"]=> string(0) ""
    }
   }
  }
 }
 ["allPlans"]=> array(1) {
  [0]=> array(5) {
   ["cursor"]=> string(24) "BtreeCursor tags_1 multi"
   ["n"]=> int(30)
   ["nscannedObjects"]=> int(30)
   ["nscanned"]=> int(30)
   ["indexBounds"]=> array(1) {
    ["tags"]=> array(2) {
     [0]=> array(2) {
      [0]=> string(7) "windows"
      [1]=> string(7) "windowt"
     }
     [1]=> array(2) {
      [0]=> object(MongoRegex)#8 (2) {
       ["regex"]=> string(8) "^windows"
       ["flags"]=> string(0) ""
      }
      [1]=> object(MongoRegex)#9 (2) {
       ["regex"]=> string(8) "^windows"
       ["flags"]=> string(0) ""
      }
     }
    }
   }
  }

 }
 ["oldPlan"]=> array(2) {
  ["cursor"]=> string(24) "BtreeCursor tags_1 multi"
  ["indexBounds"]=> array(1) {
   ["tags"]=> array(2) {
    [0]=> array(2) {
     [0]=> string(7) "windows"
     [1]=> string(7) "windowt"
    }
    [1]=> array(2) {
     [0]=> object(MongoRegex)#10 (2) {
      ["regex"]=> string(8) "^windows"
      ["flags"]=> string(0) ""
     }
     [1]=> object(MongoRegex)#11 (2) {
      ["regex"]=> string(8) "^windows"
      ["flags"]=> string(0) "" }
     }
    }
   }
 }
 ["server"]=> string(12) "host:27017"

}

But when you say that I should run the same query in console , do you want
to say that I should run the query in mongo's shell ?

I never used mongodb by shell consol . If I have to use linux shell,
how can I connect to my database ?

Le mardi 11 septembre 2012 16:29:54 UTC+2, Sammaye a écrit :

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Millman  
View profile  
 More options Sep 11 2012, 11:23 am
From: Sam Millman <sam.mill...@gmail.com>
Date: Tue, 11 Sep 2012 16:23:28 +0100
Local: Tues, Sep 11 2012 11:23 am
Subject: Re: [mongodb-user] Re: Very slow query

Mongo comes by default with two programs:

- mongod (The mongo deamon, the database itself in your eyes)
- mongo (The console app, a lot like mysql)

You can connect to it pretty much the same way as with mysql as well:

> sudo /path_to_my_mongo/mongo
> use my_db
> db.my_col.find({ //my condition in JSON form })

You can add a .explain onto the of the find and see if PHP is reading
differently to console.

In theory both should be the same speed but we will see.

On 11 September 2012 15:57, marcandre <malegr...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
marcandre  
View profile  
 More options Sep 11 2012, 11:39 am
From: marcandre <malegr...@gmail.com>
Date: Tue, 11 Sep 2012 08:39:31 -0700 (PDT)
Local: Tues, Sep 11 2012 11:39 am
Subject: Re: [mongodb-user] Re: Very slow query

OK, This is the response what I get if I type in shell consol :

db.my_collection.find({tags:/^windows/}).limit(30).skip(30).explain();
{
        "cursor" : "BtreeCursor tags_1 multi",
        "isMultiKey" : true,
        "n" : 30,
        "nscannedObjects" : 60,
        "nscanned" : 60,
        "nscannedObjectsAllPlans" : 60,
        "nscannedAllPlans" : 60,
        "scanAndOrder" : false,
        "indexOnly" : false,
        "nYields" : 0,
        "nChunkSkips" : 0,
        "millis" : 1,
        "indexBounds" : {
                "tags" : [
                        [
                                "windows",
                                "windowt"
                        ],
                        [
                                /^windows/,
                                /^windows/
                        ]
                ]
        },
        "server" : "host:27017"

}

Le mardi 11 septembre 2012 17:23:38 UTC+2, Sammaye a écrit :

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
marcandre  
View profile  
 More options Sep 11 2012, 11:45 am
From: marcandre <malegr...@gmail.com>
Date: Tue, 11 Sep 2012 08:45:45 -0700 (PDT)
Local: Tues, Sep 11 2012 11:45 am
Subject: Re: [mongodb-user] Re: Very slow query

Another thing, if I type  

db.my_collection.find({tags:/^windows/}).limit(30).skip(30);

(without explain()) I get an UTF-8 error in my consol (I have got french
title in data) , I don't know if it is the cause of this slowness .

Le mardi 11 septembre 2012 17:39:31 UTC+2, marcandre a écrit :

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
marcandre  
View profile  
 More options Sep 11 2012, 3:50 pm
From: marcandre <malegr...@gmail.com>
Date: Tue, 11 Sep 2012 12:50:06 -0700 (PDT)
Local: Tues, Sep 11 2012 3:50 pm
Subject: Re: [mongodb-user] Re: Very slow query

I don't know why is there a lot of differences between the results in php
and the shell consol when I execute explaine() for the same request

From consol :

db.my_collection.find({tags:/^windows/}).limit(30).skip(30).explain();
{
"cursor" : "BtreeCursor tags_1 multi",
"isMultiKey" : true,
"n" : 30,
"nscannedObjects" : 60,
"nscanned" : 60,
"nscannedObjectsAllPlans" : 60,
"nscannedAllPlans" : 60,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 1,
"indexBounds" : {
"tags" : [
[
"windows",
"windowt"
],
[
/^windows/,
/^windows/
]
]

},

"server" : "host:27017"

}

From php :

array(16) {
["cursor"]=> string(24) "BtreeCursor tags_1 multi"
["isMultiKey"]=> bool(true)
["n"]=> int(30)
["nscannedObjects"]=> int(30)
["nscanned"]=> int(30)
["nscannedObjectsAllPlans"]=> int(30)
["nscannedAllPlans"]=> int(30)
["scanAndOrder"]=> bool(false)
["indexOnly"]=> bool(false)
["nYields"]=> int(0)
["nChunkSkips"]=> int(0)
["millis"]=> int(0)
["indexBounds"]=> array(1) {
["tags"]=> array(2) {
[0]=> array(2) {
[0]=> string(7) "windows"
[1]=> string(7) "windowt"

}

[1]=> array(2) {
[0]=> object(MongoRegex)#6 (2) {
["regex"]=> string(8) "^windows"
["flags"]=> string(0) ""
}

[1]=> object(MongoRegex)#7 (2) {
["regex"]=> string(8) "^windows"
["flags"]=> string(0) ""
}
}
}
}

["allPlans"]=> array(1) {
[0]=> array(5) {
["cursor"]=> string(24) "BtreeCursor tags_1 multi"
["n"]=> int(30)
["nscannedObjects"]=> int(30)
["nscanned"]=> int(30)
["indexBounds"]=> array(1) {
["tags"]=> array(2) {
[0]=> array(2) {
[0]=> string(7) "windows"
[1]=> string(7) "windowt"
}

[1]=> array(2) {
[0]=> object(MongoRegex)#8 (2) {
["regex"]=> string(8) "^windows"
["flags"]=> string(0) ""
}

[1]=> object(MongoRegex)#9 (2) {
["regex"]=> string(8) "^windows"
["flags"]=> string(0) ""

}
}
}
}
}
}

["oldPlan"]=> array(2) {
["cursor"]=> string(24) "BtreeCursor tags_1 multi"
["indexBounds"]=> array(1) {
["tags"]=> array(2) {
[0]=> array(2) {
[0]=> string(7) "windows"
[1]=> string(7) "windowt"
}

[1]=> array(2) {
[0]=> object(MongoRegex)#10 (2) {
["regex"]=> string(8) "^windows"
["flags"]=> string(0) ""
}

[1]=> object(MongoRegex)#11 (2) {
["regex"]=> string(8) "^windows"
["flags"]=> string(0) "" }
}
}
}
}

["server"]=> string(12) "host:27017"

}

Best regards.

Le mardi 11 septembre 2012 17:45:45 UTC+2, marcandre a écrit :

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
marcandre  
View profile  
 More options Sep 12 2012, 10:24 am
From: marcandre <malegr...@gmail.com>
Date: Wed, 12 Sep 2012 07:24:42 -0700 (PDT)
Local: Wed, Sep 12 2012 10:24 am
Subject: Re: [mongodb-user] Re: Very slow query

Hellow everybody,

I come back to you and I'm looking for  a solution for my query slowness
from php again .
Is there someone can suggest me something about this problem ?

Best regards .

Le mardi 11 septembre 2012 21:50:06 UTC+2, marcandre a écrit :

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »