query-optimization

Cacheable(), FetchMany() and ToFuture() in same NHibernate Linq query

房东的猫 提交于 2019-12-08 02:18:23
问题 Having a situation similar to the following example: 1 parent entity Employee having 2 child collections: Addresses and Phones I need to retrieve in a single roundtrip all employees with their Addresses and Phones initialized and also cache the query that achieves that in level 2 cache using Cacheable() . Using: var baseQuery = session .Query<Employee>() .Cacheable(); baseQuery .FetchMany(e => e.Addresses) .ToFuture(); var list = baseQuery .FetchMany(e => e.Phones) .ToFuture() .ToList();

MySQL select with a count query on another table

ぃ、小莉子 提交于 2019-12-08 01:50:51
问题 I have simple article application with three tables: article id, title, body, user_id comment id, article_id, user_id, body user id, username On the landing page, I want to show the latest article titles with the author name and total numbers of comments of the article. The main problem is how to get total numbers of comments of the article,I did not get it right. I should get the following output: title username total_comments article 2 user2 0 article 1 user1 2 In my real application, I

Optimization of SPARQL query. [ Estimated execution time exceeds the limit of 1500 (sec) ]

余生颓废 提交于 2019-12-07 17:52:19
问题 I am trying to run this query on http://dbpedia.org/sparql but I get an error that my query is too expensive. When I run the query trough http://dbpedia.org/snorql/ I get: The estimated execution time 25012730 (sec) exceeds the limit of 1500 (sec) ... When running the query through my python script using SPARQLWrapper I simply get an HTTP 500. I figure I need to do something to optimize my SPARQL query. I need the data for iterating over educational institutions and importing it in to a local

How Bitmap Heap Scan and Index Scan is decided?

别来无恙 提交于 2019-12-07 03:49:30
问题 I'm testing different queries and I'm curious about how db decide using Bitmap Heap Scan and Index Scan. create index customers_email_idx on customers(email varchar_pattern_ops); As you can see there is a customers table (dellstore example) and I add an index to email column. First query is here: select * from customers where email like 'ITQ%@dell.com'; -> query with Index Scan Explain analyze query is here: QUERY PLAN --------------------------------------------------------------------------

mysql NOT IN QUERY optimize

守給你的承諾、 提交于 2019-12-07 02:06:06
问题 I have two tables named as: table_product table_user_ownned_auction table_product specific_product_id astatus ... (primary_key,autoinc) -------------------------------------- 1 APAST ... 2 ALIVE ... 3 ALIVE ... 4 APAST ... 5 APAST ... table_user_ownned_auction own_id specific_product_id details ---------------------------------------- 1 1 XXXX 2 5 XXXX I need to select atatus = APAST , and not in table 2. Which means, in above structure table1 has 3 APAST status (1,4,5). But in table 2

Optimizing my mysql query to use index for sorting

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 01:40:25
问题 I have a composite index based on 3 columns, two of which are constrained in my query and the 3rd is in order by clause yet mysql doesn't use index for sorting. explain select * from videos where public_private='public' and approved='yes' order by number_of_views desc; +----+-------------+--------+------+--------------------------------+------+---------+------+---------+-----------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +---

SQLite table taking time to fetch the records in LIKE query

佐手、 提交于 2019-12-07 00:40:32
Scenario : database is sqlite (need to encrypt records in database. Hence used SQL cipher API for iOS) There is a table in the database named partnumber with schema as follows: CREATE TABLE partnumber ( objid varchar PRIMARY KEY, description varchar, make varchar, model varcha, partnumber varchar, SSOKey varchar, PMOKey varchar ) This table contains approximately 80K records. There are 3 text fields in the UI view, in which user can enter search terms and searching is made as soon as user enters the letters there. 3 text fields are: txtFieldDescription, txtFieldMake and txtFieldModel. Suppose,

SQL Server Profiler: How to inspect/understand the duration for the Audit Logout event in more detail?

假如想象 提交于 2019-12-06 19:54:33
I am profiling some MS SQL queries with the SQL Server Profiler for my C# Application that I develop with Visual Studio and IIS Express: The duration that is given for the event "Audit Logout" (16876 ms) is the total time between login and logout. The duration for the query is only 60 ms. Login/Logout events are related to the setting up / tearing down. From What is "Audit Logout" in SQL Server Profiler? I would like to understand the time difference of 16816 ms (= 16876 ms - 60ms) in more detail. a) Is it possible to log more events (like a "debug mode")? b) Is it right to assume that the

SQL question from Joel Spolsky article

こ雲淡風輕ζ 提交于 2019-12-06 19:34:59
问题 From Joel Spolsky's article on leaky abstractions: [C]ertain SQL queries are thousands of times slower than other logically equivalent queries. A famous example of this is that some SQL servers are dramatically faster if you specify "where a=b and b=c and a=c" than if you only specify "where a=b and b=c" even though the result set is the same. Does anyone know the details of this? 回答1: Obviously, a = b and b = c => a = c - this is related to transitive closure. The point Joel was making is

MySQL: Why does an Order By ID runs much slower than Order By other Columns?

末鹿安然 提交于 2019-12-06 18:24:46
问题 I am using MySQL version 5.5.14 to run the following query, QUERY 1 , from a table of 5 Million rows: SELECT P.ID, P.Type, P.Name, P.cty , X(P.latlng) as 'lat', Y(P.latlng) as 'lng' , P.cur, P.ak, P.tn, P.St, P.Tm, P.flA, P.ldA, P.flN , P.lv, P.bd, P.bt, P.nb , P.ak * E.usD as 'usP' FROM PIG P INNER JOIN EEL E ON E.cur = P.cur WHERE act='1' AND flA >= '1615' AND ldA >= '0' AND yr >= (YEAR(NOW()) - 100) AND lv >= '0' AND bd >= '3' AND bt >= '2' AND nb <= '5' AND cDate >= NOW() AND MBRContains