indexing

How to Optimize the Use of the “OR” Clause When Used with Parameters (SQL Server 2008)

删除回忆录丶 提交于 2020-01-20 04:53:06
问题 I wonder if there is any wise way to rewrite the following query so that the indexes on columns get used by optimizer? CREATE PROCEDURE select_Proc1 @Key1 int=0, @Key2 int=0 AS BEGIN SELECT key3 FROM Or_Table WHERE (@key1 = 0 OR Key1 = @Key1) AND (@key2 = 0 OR Key2 = @Key2) END GO According to this article How to Optimize the Use of the "OR" Clause When Used with Parameters by Preethiviraj Kulasingham: Even though columns in the WHERE clauses are covered by indexes, SQL Server is unable to

Get index of clicked element using pure javascript

試著忘記壹切 提交于 2020-01-18 07:07:51
问题 I need to know the index of clicked element. Can't figure out how to do it for (i = 0; i < document.getElementById('my_div').children.length; i++) { document.getElementById('my_div').children[i].onclick = function(){'ALERT POSITION OF CLICKED CHILD'}; } this.index? here is a example of what I am trying to do (it only gives back 6): <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Untitled Document</title> <style type="text/css"> body{margin:0;} #container div{height:50px;line

Get index of clicked element using pure javascript

久未见 提交于 2020-01-18 07:07:27
问题 I need to know the index of clicked element. Can't figure out how to do it for (i = 0; i < document.getElementById('my_div').children.length; i++) { document.getElementById('my_div').children[i].onclick = function(){'ALERT POSITION OF CLICKED CHILD'}; } this.index? here is a example of what I am trying to do (it only gives back 6): <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Untitled Document</title> <style type="text/css"> body{margin:0;} #container div{height:50px;line

Python pandas slice dataframe by multiple index ranges

走远了吗. 提交于 2020-01-18 04:41:06
问题 What is the pythonic way to slice a dataframe by more index ranges (eg. by 10:12 and 25:28 )? I want this in a more elegant way: df = pd.DataFrame({'a':range(10,100)}) df.iloc[[i for i in range(10,12)] + [i for i in range(25,28)]] Result: a 10 20 11 21 25 35 26 36 27 37 Something like this would be more elegant: df.iloc[(10:12, 25:28)] 回答1: You can use numpy's r_ "slicing trick": df = pd.DataFrame({'a':range(10,100)}) df.iloc[pd.np.r_[10:12, 25:28]] Gives: a 10 20 11 21 25 35 26 36 27 37 回答2:

Pyspark, error:input doesn't have expected number of values required by the schema and extra trailing comma after columns

我只是一个虾纸丫 提交于 2020-01-17 18:51:09
问题 First I made two tables(RDD) to use following commands rdd1=sc.textFile('checkouts').map(lambda line:line.split(',')).map(lambda fields:((fields[0],fields[3],fields[5]), 1) ) rdd2=sc.textFile('inventory2').map(lambda line:line.split(',')).map(lambda fields:((fields[0],fields[8],fields[10]), 1) ) The keys in first RDD are BibNum, ItemCollection and CheckoutDateTime. And when I checked the values for first RDD to use rdd1.take(2) it shows [((u'BibNum', u'ItemCollection', u'CheckoutDateTime'), 1

Pyspark, error:input doesn't have expected number of values required by the schema and extra trailing comma after columns

前提是你 提交于 2020-01-17 18:50:06
问题 First I made two tables(RDD) to use following commands rdd1=sc.textFile('checkouts').map(lambda line:line.split(',')).map(lambda fields:((fields[0],fields[3],fields[5]), 1) ) rdd2=sc.textFile('inventory2').map(lambda line:line.split(',')).map(lambda fields:((fields[0],fields[8],fields[10]), 1) ) The keys in first RDD are BibNum, ItemCollection and CheckoutDateTime. And when I checked the values for first RDD to use rdd1.take(2) it shows [((u'BibNum', u'ItemCollection', u'CheckoutDateTime'), 1

unique constraint makes hashes useless?

浪子不回头ぞ 提交于 2020-01-17 12:28:06
问题 I am confused if in MySQL unique constraint is physical index or virtual index? And as unique constraint is defined on a column then, Is there any need to make a hash column also and defining index on hash column to speed up the process of queries considering that unique constraint column contains variable number of characters mostly above 40 characters and on average 50+? And total records are 150+ million plus. I have asked another question with details of hashes and its indexing plan.

Multi Indexed in Collection with O(1) searching time

不羁岁月 提交于 2020-01-17 07:40:50
问题 Suppose I want to make one Collection of Class which have 10 properties, This collection holds about 10 million items. Now I want to search this collection with O(1) time complexity or near to O(1) by any property of Class.(Not by only one property i.e ID or Name) If I use List than it by LINQ query it will require O(n) time complexity, So it can't be used. C# have dictionary which can be indexed by only one key type. So it also can't be used. As one solution I can make 10 Dictionaries

Why won't MySQL use my index?

心不动则不痛 提交于 2020-01-17 07:24:27
问题 If I have the following table: CREATE TABLE `mytable` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(64) DEFAULT NULL, PRIMARY KEY (`id`), KEY `name_first_letter` (`name`(1)), KEY `name_all` (`name`) ) Will MySQL ever choose to use the name_first_letter index over the name_all index? If so, under what conditions would this happen? I have done some quick tests and I'm not sure if MySQL will choose the name_first_letter index even when using index hints: -- This uses name_all EXPLAIN SELECT

Use Index Match to Return Value Using Lookup Value from Multiple Columns

陌路散爱 提交于 2020-01-17 06:23:20
问题 I'm trying to return a value from one column using values from a range of 3 columns. When I enter an electrical, plumbing or gas permit number into a report (D14) I want the corresponding building permit number to be entered into another cell as the file reference. The report is one worksheet and the list of permit numbers is another worksheet in the same workbook. It's one permit one report so I don't think I need anything complicated. VLOOKUP didn't work because I need to search right to