select RID takes forever in Orientdb - orientdb

I am new to Orientdb, and just downloaded the latest Mac OS version, created a new databases, and created a new class named Person, which contains a first name and a last name.
Then I created 1,000,000 fake users to test the speed. However, when I run the query
select RID from Person offset 999999
The process rans 67.569 seconds!
Following is the screen shot:
I have 2 questions:
1) Why does it take sooooo long..
2) Why is the result "#-2:1" rather than "#11:1000000"? (11 is the index of my Person class)
Updated
Now I noticed I should query for pagination like
SELECT FROM Person WHERE #rid > #11:999998 LIMIT 2
But it still takes 8.224s on my Macbook Air. Is it normal?

Related

how do u use a group by when using fields from different tables

Ive tried running the following query on my database but when I do it shows the wrong information
I am trying to show every product that has been bought and who bought it and instead It shows that every product has been bought by every customer.
SELECT Cust_Name, prod_type, purchases.purch_id
FROM CUSTomers, product, purchases, orders
Where Purchases.purch_id = orders.PURCH_ID
AND orders.prod_id=product.prod_id;
when I have asked my lecturer how i should change the query I was told I should be look into group by clause but when I add one I get the error message "ORA-00979: not a GROUP BY expression"
This is the structure of the relevant tables

Unable to retrieve the latest data from DB2 using with ur clause

We are facing one interesting issue in my production DB.
We are using Db2 data base , after issuing update command(from command center, dqlsuirrel....all) and commit , not able to retrieve the latest data/updated data from select query with UR(It is returning previous data).But if i use the select clause with RR then i am able to see the latest data.
One more interesting thing if update the data today , i can't get the latest by using Select with UR on the same day but i am able to retrive the latest data(which i updated on previous day) on next day (By using select ...from ABC with UR).
I found the problem.
A MQT is created on this base table(XYZ) so whenever i query the against table (XYZ) it is getting data from MQT table/buffer.

Visualizing graph with OrientDB Studio

I'm working with OrientDB (2.2.10) and occasionaly I would like to visually inspect my dataset to make sure I'm doing things correctly. On this page of OrientDB http://orientdb.com/orientdb/ you see a nice visualization of a large graph with the following query:
select * from V limit -1;
So I tried the same query on my dataset but the result is so extremely sluggish that I can't work with it. My dataset is not extremely large (few hundred vertices, couple thousand edges) but still the result is unworkable. I tried all major browsers but with all I have the same result. Also my computer is not underpowered, I have a quad-core i7 with 16GB RAM.
As a very simple example I have the following graph:
BAR --WITHIN---> CITY --LOCATED_IN--> COUNTRY
Here: Find "friends of friends" with OrientDB SQL I was able to get at least an example of how to do this type of query on a graph. I managed to get a subset of my graph for example as follows:
select expand(
bothE('WITHIN').bothV()
) from Bar where barName='Foo' limit -1
This get's me the graph of 1 Bar vertex, the edge WITHIN and the City vertex. But if I now want to go one step further by also fetching the country which the city is located in I cannot get this style of query to work for me. I tried this:
select expand(
bothE('WITHIN').bothV()
.bothE('LOCATED_IN').bothV()
) from Bar where barName='Foo' limit -1
This results in the same subset being shown. However, if I first run the first query and then without clearing the canvas run the second query I do get the 3 vertices. So it seems I'm close but I would like to get all 3 vertices and it's edges in one query, not having to run first the one and then the other. Could someone point me in the right direction?
If you want to get all three vertices, it would be much easier start from the middle (city) and than get in and out to get bar and contry. I've tried with a similar little structure:
To get city, bar name and country you can try a query like this:
select name, in("WITHIN").name as barName,out("LOCATED_IN").name as barCountry from (select from City where name='Milan') unwind barName, barCountry
And the output will be:
Hope it helps.
If it is not suitable for your case, let me know.
You could use
traverse * from (select from bar where barName='Foo') while $depth <= 4
Example: I tried with this little graph
and I got
Hope it helps.

How to make a fake join in MongoDB?

I am developing a webapp using PHP and MongoDB. In this app I keep two collections. One to keep data about files and one to keep track about download events for each file.
I need to get the 10 latest downloaded files but I know joins is not an option. The events document only stores the file id and the other collection stores the thumbnail.
Right now I first get the 10 recently downloaded files and order it by date and the order is fine but then I use this array of files (their ids) and make a where_in query where I look for files whos id is present in the ids array. This also works fine (I get the thumbnails for the selected files) but I cannot keep the order anymore. The most recently downloaded file is not longer on top.
How can I keep the order of the ids without looping through them thus making 10 new queries instead of just one?
I cannot change the schema because I got over 40.000 documents :)
UPDATE
In short this is what I want to do:
Get all the IDs of the 10 recently downloaded files. Sorted by download timestamp.
Use this array of Ids and make a query to the files collection and get the details for each file like thumbnail, decription and so on.
The above steps works fine, BUT I cannot keep the order from the first step thus I cannot get the most recently downloaded file on top. I know I could look trought the id array and get data for each file but that would cost me 10 queries instead of one.
I don't really get your problem. Here's some pseudo-code:
// get last N download events
events = get_latest_downloads()
// retrieve associated file data
file_array = get_all_file_info_by_events(events)
display_data = []
for(e in events) {
data = find_file_info_in_the_array(file_array, e.file_id)
display_data.push(data)
}
// now display_data is contains full file info, sorted by download time.

Zend_Paginator - Increase querys

I started using Zend_Paginator,
it works everything fine but I noticed that there is one more query which slows the load time down.
The additional query:
SELECT COUNT(1) AS `zend_paginator_row_count` FROM `content`
The normal query:
SELECT `content`.`id`, `content`.`name` FROM `content` LIMIT 2
PHP:
$adapter = new Zend_Paginator_Adapter_DbSelect($table->select()->from($table, array('id', 'name')));
$paginator = new Zend_Paginator($adapter);
Could I merge the two querys into one (for better performance)?
Make sure you have an index on one or more int-based columns of the selected table. So the count query will not have much of a performance inpact. You can use setRowCount() to provide the count (if you have it).
From http://framework.zend.com/manual/en/zend.paginator.usage.html :
Note: Instead of selecting every
matching row of a given query, the
DbSelect and DbTableSelect adapters
retrieve only the smallest amount of
data necessary for displaying the
current page. Because of this, a
second query is dynamically generated
to determine the total number of
matching rows. However, it is possible
to directly supply a count or count
query yourself. See the setRowCount()
method in the DbSelect adapter for
more information.
Merging the two wouldn't really have much of a performance increase if any. The actual select content has the limit statement in it (as you are trying to get a subset of the entire table in the database) where the count needs to count all rows in the database. The reason it is done like this is to prevent having to select a very large set of data simply to get the count.