|
In an (m by n) array stored as double *d (column major), what is the fastest way of selecting a range of rows and or columns:
double *filter(double *mat, int m, int n, int rows[], int cols[]);
invoked as:
double *B; int rows[]= {1,3,5}; int cols[]={2,...
Answer Snippets (Read the full thread at stackoverflow):
Of items of rows and n should be the number of items in cols) and not the dimension of the source that those will be valid) and b) if you don't know the size of rows and columns they are useless memory for an m x n array For each i in 0....
|
|
This may seem as a typical plyr problem, but I have something different in mind. Here's the function that I want to optimize (skip the for loop).
# dummy data set.seed(1985) lst <- list(a=1:10, b=11:15, c=16:20) m <- matrix(round(runif(200, 1, 7...
Started by aL3xa on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Function on each part, by row subs[[i]] <- apply(dt[ , lst[[i]]], 1, fun) }
with
subs <- llply(lst.
|
|
I have a QTableView using a QSqlTableModel .
In the underlying database (postgresql) table there is a timestamp column.
How can I select all rows in the selection model where the underlying timestamp column is NULL?
Pointers in the right direction would...
Started by Karl Voigtland on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
To access the model's data, you can use QSqlQueryModel.
To do so, loop through the entire model and determine which rows have NULL as the timestamp.
You'll need to determine which rows to select.
|
Ask your Facebook Friends
|
I've got a production DB with, say, ten million rows. I'd like to extract the 10,000 or so rows from the past hour off of production and copy them to my local box. How do I do that?
Let's say the query is:
SELECT * FROM mytable WHERE date > '2009-0...
Started by Mike on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Questions/414849/whats-the-best-way-to-copy-a-subset-of-a-tables-rows-from-one-database-to-anoth> "%i rows retrieved" % old_cursor.rowcount new_cursor.execute("""BEGIN""") placeholders = [] namesandvalues = {} for name in names....
|
|
I'm working on returning a recordset from SQL Server 2008 to do some pagination. I'm only returning 15 records at a time, but I need to have the total number of matches along with the subset of records. I've used two different queries with mixed results...
Started by Daniel Short on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
990
which avoided having to count all rows row count, but using the query plan to give me an estimated row count, a bit like the first item was then to deliver whatever....
The estimated row count, like
rows 900-915 of approx.
|
|
We're inherting a project at work from another office that has closed down. The production database is around 150GB and we're shying away from copying this to 4 dev machines to work from. Are there any scripts, utilities or suggestions on how we can go...
Started by WesleyJohnson on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Rinse and repeat% of the database thats left behind....
"Customers") and recursively fetch any dependent rows from dependent tables.
Relationships between tables are, and how you find all the dependencies of a given row in a given table (e.g.
|
|
I want to left join TableA to TableB where a certain condition in tableA is true So I do this type of SQL query
Select * from TableA Left Join TableB on TableA.fld1 = TableB.fld2 where TableA.fld3 = True
This works OK. Now however I want to do the Join...
Started by jjb on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Try this:
Select * from TableA and TableB.fld4 = False where TableA.fld... .
When you have a where clause that filters rows on the "right" side of a left join query, you ultimately exclude rows.
You should put the condition in the join clause.
|
|
Are the following queries effective in MySQL:
SELECT * FROM table WHERE field & number = number; # to find values with superset of number's bits SELECT * FROM table WHERE field | number = number; # to find values with subset of number's bits
...if an ...
Started by Omeoe on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Amount of rows, and that the "bitwised" criteria remain selective enough) a possible optimization is achieved when avoiding a bitwise operation on every single row, by rewriting the query this need to be evaluated with different use cases....
|
|
I have an application that (unfortunately) contains a lot of its business logic is stored procedures.
Some of these return masses of data. Occassionally the code will need a small amount of the data returned from the stored procedure. To get a single ...
Started by Mongus Pong on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
You have to create a new stored proc (to return what you want) or modify the current one (to branch) if you want to do this: project politics can not change real life
Edit: I didn't tell... .
A stored procedure is a single executable entity.
No, you can't.
|
|
I guess there will be a very simple answer to this. But here goes.
Data in long format. like this
d <- data.frame(cbind(numbers = rnorm(10), year = rep(c(2008, 2009), 5), name = c("john", "David", "Tom", "Kristin", "Lisa","Eve","David","Tom","Kristin...
Started by Andreas on
, 5 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
If there is only one record per year, just count up the number for everyone who appeared twice:
subset....
In rows:
library(reshape) cast(d, name ~ year, value = "numbers")
You could then use complete.cases to extract the rows of interest.
|