indexing

Efficient sorted bounding box query

笑着哭i 提交于 2019-12-25 08:05:07
问题 How would I create indexes in PostgresSQL 8.3 which would make a sorted bounding box query efficient? The table I'm querying has quite a few rows. That is I want the create indexes that makes the following query as efficient as possible: SELECT * FROM features WHERE lat BETWEEN ? AND ? AND lng BETWEEN ? AND ? ORDER BY score DESC The features table look like this: Column | Type | ------------+------------------------+ id | integer | name | character varying(255) | type | character varying(255)

get distinct list (index) if adjacent value equals a specific text in excel

浪尽此生 提交于 2019-12-25 08:04:08
问题 I would like to get a distinct list of column J if cell in H of same row equals "No Company". I tried =IFERROR(INDEX($J$2:$J$10, MATCH(0, COUNTIF($K$1:K2, $J$2:$J$10&"") + IF(ISTEXT($H$2:$H$10)="No company",1,0), 0)), "")) also tried =IFERROR(INDEX(J$2:J$400, SMALL(IF((H$2:H$400=No company)>1)), ROW(j$2:j$400)-ROW(j$2)+1), ROWS(j$2:j2)), "") changing some of the fields but no luck Desired result + Try 回答1: Create a new function: open VBA Editor (alt + F11), add new module, insert code:

Calling a DB function from Hibernate

狂风中的少年 提交于 2019-12-25 07:56:38
问题 I am trying to build a job that reindexes our DB every Friday. We are using hibernate and everything I have tried so far has failed. Is there a way to execute SQL managament commands using hibernate? Such as: Session session = helper.getSession(); session.createQuery("DBCCREINDEX(User)").executeUpdate(); Or is there a better way to reindex within Hibernate? 回答1: The examples referenced below are for Oracle PL/SQL but conceptually it's the same for other databases. By "build a job" and

indexing/slicing in numpy array to modify it

久未见 提交于 2019-12-25 07:49:50
问题 I have a numpy array A and I want to modify values in it using a indexing list B. But the thing is in my slicing I can have an element of the array multiple times... This example will explain better what I mean by that : import numpy as np A = np.arange(5) + 0.5 B = np.array([0, 1, 0, 2, 0, 3, 0, 4]) print A[B] returns as expected [ 0.5 1.5 0.5 2.5 0.5 3.5 0.5 4.5] . However if I do that : A[B] += 1. print A I was expecting to obtain [ 4.5 2.5 3.5 4.5 5.5] as the first element is repeated 4

I use $_POST and index is undefined?

时间秒杀一切 提交于 2019-12-25 07:47:45
问题 I am using the code show below for a search and it is working. But when I try it to display another page with other results it says that “the index is undefined". I'm using again in this file but it does not solve anything. Can anyone tell me why is this happening? The error is: Notice: Undefined index: pesquisa in J:\xampp\htdocs\pesquisa3.php on line 32 The code is: <?php session_start(); if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) { header ("Location: login.php"); } ?>

Best approach to select most viewed posts from last n hours

不打扰是莪最后的温柔 提交于 2019-12-25 07:34:17
问题 I'm using PHP and MYSQL(innodb engine). As MYSQL reference says, selecting with comparison of one column and ordering by another can't use our considered index. I have a table named News . This table has at least 1 million records with two important columns: time_added and number_of_views . I need to select most viewed records from last n hours. What is the best index to do this? Or is it possible to run this kind of queries very fast for a table with millions of records? I've already done

Use list of nested indices to access list element

拈花ヽ惹草 提交于 2019-12-25 07:32:23
问题 How can a list of indices (called "indlst"), such as [[1,0], [3,1,2]] which corresponds to elements [1][0] and [3][1][2] of a given list (called "lst"), be used to access their respective elements? For example, given indlst = [[1,0], [3,1,2]] lst = ["a", ["b","c"], "d", ["e", ["f", "g", "h"]]] (required output) = [lst[1][0],lst[3][1][2]] The output should correspond to ["b","h"]. I have no idea where to start, let alone find an efficient way to do it (as I don't think parsing strings is the

Array with a valid index is not returning the right status code in c

别等时光非礼了梦想. 提交于 2019-12-25 07:01:22
问题 I have two functions here, which for intarr_set(), if an index is valid, I would set the value at ia[index] to val and return INTARR_OK which is a status code, and the other function intarr_get() would set *i to ia[index] if the index is valid as well. But when I was testing my function with a random array I generated, which was [ 11 49 36 3 69 21 72 73 94 69 2 22 2 96 64 93 ], I got a message saying that my intarr_get() function didn't return INTARR_OK even though I got a valid index. Does

Postgres reverse LIKE lookup indexing and performance

两盒软妹~` 提交于 2019-12-25 06:53:22
问题 We have a musicians table containing records with multiple string fields, say: "Jimi", "Hendrix", "Guitar" "Phil", "Collins", "Drums" "Sting", "", "Bass" "Ringo", "Starr", "Drums" "Paul", "McCartney", "Bass" I want to pass postgres a long string, say: "It is known that Jimi liked to set light to his guitar and smash up all the drums while on stage." and i want to get returned the fields that have any matches - preferably in order of the most matches first: " Jimi ", "Hendrix", " Guitar "

Apache nutch: Manipulating the DOM before parsing

点点圈 提交于 2019-12-25 06:45:59
问题 I want to remove specific elements from the page response, before it is handed down to nutch. Specifically, I want to mark parts of my pages with i.e. <div class="noindex">I shall not be indexed</div> And want to remove them before nutch parse, so that "I shall not be indexed" is not present in the NutchDocument afterwards. I plan die surround my navigation, header, footer content with this because right now, they are present in every document in the index. Thanks, Paul 回答1: You have some