query-optimization

Can Mysql cache calls to same function with same arguments

☆樱花仙子☆ 提交于 2021-02-19 05:43:13
问题 For example I have this condition WHERE f1=CONCAT(v1,v2) OR f2=CONCAT(v1,v2) -- /*... where v1,v1 are static, then Mysql must cache result of concat after first call. If v1 is field, then Mysql must cache result of concat after first call, but only for current row. So, Mysql doing this? 回答1: No, MySQL does not cache function calls. Furthermore, such an optimization would not be worth doing. Note the tiny difference: mysql> SELECT city, country, CONCAT(city, country) FROM cities LIMIT 263000,5

Optimizing Hive GROUP BY when rows are sorted

北城余情 提交于 2021-02-19 05:31:39
问题 I have the following (very simple) Hive query: select user_id, event_id, min(time) as start, max(time) as end, count(*) as total, count(interaction == 1) as clicks from events_all group by user_id, event_id; The table has the following structure: user_id event_id time interaction Ex833Lli36nxTvGTA1Dv juCUv6EnkVundBHSBzQevw 1430481530295 0 Ex833Lli36nxTvGTA1Dv juCUv6EnkVundBHSBzQevw 1430481530295 1 n0w4uQhOuXymj5jLaCMQ G+Oj6J9Q1nI1tuosq2ZM/g 1430512179696 0 n0w4uQhOuXymj5jLaCMQ G

bson.D vs bson.M for find queries

孤街醉人 提交于 2021-02-19 04:20:05
问题 This specifc question is in relation to using mongodb with the golang package mongo-driver, but I would assume this applies across most interfaces with mongodb. When using Find to query some data from a collection, we can use both the bson.M- and bson.D-type to specify the filter for this find. As per the documentation bson.D should be used if the order of elements matters and bson.M should be used otherwise. D is an ordered representation of a BSON document. This type should be used when the

Django: Why is Foo.objects.extra(…) So Much Faster Than Foo.objects.raw?

匆匆过客 提交于 2021-02-19 01:59:28
问题 So I am trying to optimize a fairly odd query, but this is a legacy database so I make do with what I have. These are the queries I am trying. They provide the same output at this point. w is my queryset. def future_schedule(request): past = datetime.date.today()-datetime.timedelta(days=730) extra_select = { 'addlcomplete': 'SELECT Complete FROM tblAdditionalDates WHERE Checkin.ShortSampleID = tblAdditionalDates.ShortSampleID', 'addldate': 'SELECT AddlDate FROM tblAdditionalDates WHERE

Performance tuning a DECODE() statement in a WHERE clause

*爱你&永不变心* 提交于 2021-02-11 13:38:04
问题 I re-wrote a query to reduce the time it takes to pick the records. But still I see that there is a small tuning that needs to be done in the decode line as the cost is high. Can someone please let me know if the same query can be re-written without the decode functionality? The purpose of removing the decode function would be to use the index in v_id column. What I have tried so far. Tried creating a function index (Knowing that bind variables cannot be used) and it failed. Have tried using

MySQL- optimize case statement

杀马特。学长 韩版系。学妹 提交于 2021-02-11 10:07:26
问题 I have a query with many case statements SELECT case when (std_no like '070%' or std_no like '071%') then 'A' when (std_no like '077%' or std_no like '076%') then 'B' when std_no like '075%' then 'C' when std_no like '072%' then 'D' when std_no like '078%' then 'E' when (std_no not like '07%' and std_no not like '00%' and std_no not like '0100%' and substring(std_no,4,1) in('2','3')) then 'F' when (std_no not like '07%' and std_no not like '00%' and std_no not like '0100%' and substring(std

MySQL- optimize case statement

我们两清 提交于 2021-02-11 10:04:32
问题 I have a query with many case statements SELECT case when (std_no like '070%' or std_no like '071%') then 'A' when (std_no like '077%' or std_no like '076%') then 'B' when std_no like '075%' then 'C' when std_no like '072%' then 'D' when std_no like '078%' then 'E' when (std_no not like '07%' and std_no not like '00%' and std_no not like '0100%' and substring(std_no,4,1) in('2','3')) then 'F' when (std_no not like '07%' and std_no not like '00%' and std_no not like '0100%' and substring(std

Cassandra Query Performance: Using IN clause for one portion of the composite partition key

穿精又带淫゛_ 提交于 2021-02-10 05:42:11
问题 I currently have a table set up in Cassandra that has either text, decimal or date type columns with a composite partition key of a business_date and an account_number. For queries to this table, I need to be able to support look-ups for a single account, or for a list of accounts, for a given date. Example: select x,y,z from my_table where business_date = '2019-04-10' and account_number IN ('AAA', 'BBB', 'CCC') //Note: Both partition keys are provided for this query I've been struggling to

Cassandra Query Performance: Using IN clause for one portion of the composite partition key

大城市里の小女人 提交于 2021-02-10 05:41:48
问题 I currently have a table set up in Cassandra that has either text, decimal or date type columns with a composite partition key of a business_date and an account_number. For queries to this table, I need to be able to support look-ups for a single account, or for a list of accounts, for a given date. Example: select x,y,z from my_table where business_date = '2019-04-10' and account_number IN ('AAA', 'BBB', 'CCC') //Note: Both partition keys are provided for this query I've been struggling to

Cassandra Query Performance: Using IN clause for one portion of the composite partition key

感情迁移 提交于 2021-02-10 05:41:15
问题 I currently have a table set up in Cassandra that has either text, decimal or date type columns with a composite partition key of a business_date and an account_number. For queries to this table, I need to be able to support look-ups for a single account, or for a list of accounts, for a given date. Example: select x,y,z from my_table where business_date = '2019-04-10' and account_number IN ('AAA', 'BBB', 'CCC') //Note: Both partition keys are provided for this query I've been struggling to