Hello everybody!
We have a web service which provides search over hotels. There is a problem with performance: a single request to the service takes around 5000 ms. Almost all of the time is spent in database by executing storing procedures. During the request our server (mssql2008) consumes ~90% of the processor time. When 2 requests are made in parallel the average time grows and is around 7000 ms. When number of request is increasing, the average time of response is increasing as well. We have 20-30 requests per minute.
Which kind of optimization is the best in this case having in mind that the goal is to provide stable response time for the service:
1) Try to decrease the stored procedures execution time
2) Try to find the way how to unload the server
It is interesting to hear from people who deal with booking sites. Thanks!
Hi
In my mode I am selecting a field as
$query1 = $this->db->query("SELECT dPassword
FROM tbl_login
WHERE dEmailID='[email protected]'");
How to return dpassword as a variable to my controller
I tried this way return dpassword;
I have this PHP page where the user can select and un-select items. The interface looks like this:
Now I'm using these code, when the user hit the save changes button:
foreach( $value as $al_id ){ //al_id is actually location id
//check if a record exists
//if location were assigned and leave it as is
$assigned_count = $this->AssignedLoc->checkIfAssigned( $tab_user_id, $al_id );
if( $assigned_count == 0 ){
//else if not, insert this new record
$this->insertAssigned( $tab_user_id, $company_id, $al_id );
}
}
Now my question is, how do I delete the un assigned locations? For example in the screenshot above, there are 4 assigned locations, if I'm gonna remove (or unassign) "Mercury Morong" and "GP Hagonoy" from the assigned locations, only two must remain. What are the possible solutions using PHP?
Thanks for any help!
Hi,
i have two tables
Order(id, date, note)
and
Delivery(Id, Note, Date)
I want to create a trigger that updates the date in Delivery when the date is updated in Order.
I was thinking to do something like
CREATE OR REPLACE TRIGGER your_trigger_name
BEFORE UPDATE
ON Order
DECLARE
BEGIN
UPDATE Delivery set date = ??? where id = ???
END;
How do I get the date and row id?
thanks
I want to make a festival calendar using asp.net from that I used two ajax calendar and one textbox it is a festival textbox where we enter festival which FromDate and ToDate respectively. I want to do this as following point
If I enter in textbox Christmas and Choose Fromdate=25/12/2011 and ToDate=31/12/2011 then it will be valid
If I choose fromDate=25/12/2011 and ToDate=24/12/2011 then it will invalid
If I choose Fromdate=25/12/2011 and Todate=28/12/2011 then also it is invalid because it coming in between 25/12/2011 and 31/12/2011
If I Choose fromdate=1/1/2011 and ToDate=1/1/2011 then it is valid
If I choose fromdate=21/12/2011 and 25/12/2011 then it is invalid because of already Christmas done in 1/1/2011
And all date should show in gridview like 25-dec-2011 format
Here is my code:
DateTime dt1 = Convert.ToDateTime(txt_fromdate.Text);
DateTime dt2 = Convert.ToDateTime(txt_todate.Text);
if (dt1 > dt2)
{
con.Open();
com = new SqlCommand("BTNN_MovieDB_Festival_Details_Insert", con);
com.Parameters.Add("@fromdate", SqlDbType.VarChar).Value = dateformat_mmdd(txt_fromdate.Text.ToString().Trim());
com.Parameters.Add("@todate", SqlDbType.VarChar).Value = dateformat_mmdd(txt_todate.Text.ToString().Trim());
com.Parameters.Add("@return", SqlDbType.VarChar).Direction = ParameterDirection.ReturnValue;
com.ExecuteNonQuery();
con.Close();
showdata();
}
else if (dt1 < dt2)
{
lblerror.Text = "ToDate should be greater than FromDate";
}
how do i write a query that returns aggregate sales data for California in the past x months.
----------------------- -----------------------
| order | | customer |
|-----------------------| |-----------------------|
| orderId int | | customerId int |
| customerId int | | state varchar |
| deposit decimal | -----------------------
| orderDate date |
-----------------------
-----------------------
| orderItem |
|-----------------------|
| orderId int |
| itemId int |
| qty int |
| lineTotal decimal |
| itemPrice decimal |
-----------------------
I have a table with 2 columns (see below). A member can have multiple responses to a question
RESPONSES
---------
member_id INT
response_id INT
SAMPLE DATA
member_id -- response_id
1 -- 3
1 -- 5
2 -- 1
2 -- 5
2 -- 9
3 -- 1
3 -- 5
3 -- 6
What I need to do is query the table for member that meet ALL response criteria. For example I need to select all members that have a response_id of 1 AND 5. I am using the following query:
SELECT DISTINCT member_id FROM responses WHERE response_id = 1 AND response_id = 5.
I would expect to get back member_id's 2,3. However I am getting nothing returned. I used EXPLAIN and it shows there is an error in my where query. What am I doing wrong?
Also, is there a function similar to IN where all the criteria must be met in order to return true?
Thanks for your help.
I have a scenario. Here's my table structure is:
ID LoginDate RemovalDate
----------------------------------------
1 2009/08/01 NULL
2 2009/09/12 2010/01/02
3 2009/08/31 2009/10/29
4 2010/02/17 NULL
5 2009/10/18 2009/11/22
I want a consolidated results of how many ID's were not removed in a particular month. So the result set should be
Date NotRemoved_ID
--------------------------
2009/08 2
2009/09 3
2009/10 3 [One ID got removed in 2009/10]
2010/02 2 [Two got removed in 2009/11 and 2010/01]
Please help.
I have a large number of rows that I would like to copy, but I need to change one field.
I can select the rows that I want to copy:
select * from Table where Event_ID = "120"
Now I want to copy all those rows and create new rows while setting the Event_ID to 155. How can I accomplish this?
I created a query in Microsoft Access like the one below:
SELECT Deliverables.ID, Deliverables.Title, Deliverables.Summary, Deliverables.Header_Code, Deliverables.Header_Code.Value, Deliverables.Sort_order, Deliverables.Pillar, Deliverables.Pillar.Value, Deliverables.Misc_ID
FROM Deliverables
WHERE (((Deliverables.Pillar.Value)="Link Building"));
But my problem is that this query locks my fields and I cannot make changes to the table using the query view.
Any suggestions? I am using Microsoft Access 2007
Hello,
I've 3 columns that I'd like to sort in the Excel way, i.e. sorting the first column, and for each element sorted in the first column, I'll sort the second column, and so on. Let's say I first sort alphabeticaly Countries, then for each country, I sort alphabeticaly cities. How do I do it using Linq2Sql?
Thanks for helping
I have a column that contains links. The problem is that the titles of the links are in the same column, so it looks like this:
linktitle|-|linkurl
I want link title and linkurl in separate columns.
I've created a new column for the urls, so I'm looking for a way to extract them and update the linkurl column with them. Is there any clever way to construct a query that does this?
Ok here's the deal I got one table with a bunch of client information.
Each client makes up to one purchase a year which is represented by an individual row.
there's a column for the year and there's a column the contains a unique identifier for each client. What I need to do is to construct a query that takes last year and this year and shows me which clients were here made a purchase last year but not make a purchase this year.
I also need to build a query that shows me which clients did not make a purchase last year and the year before last but did make a purchase this year.
I am working on call center project and I have to calculate the call arrivals at the same time between specific time ranges.
I have to write a procedure which has parameters StartTime, EndTime and Interval
For Example:
Start Time: 11:00
End Time: 12:00
Interval: 20 minutes
so program should divide the 1-hour time range into 3 parts and each part should count the arrivals which started and finished in this range OR arrivals which started and haven't finished yet
Should be like this:
11:00 - 11:20 15 calls at the same time(TimePeaks)
11:20 - 11:40 21 calls ...
11:40 - 12:00 8 calls ...
Any suggestions how to calculate them?
I have 4 tables: tempTBL, linksTBL and categoryTBL, extra
on my tempTBL I have: ID, name, url, cat, isinserted columns
on my linksTBL I have: ID, name, alias columns
on my categoryTBL I have: cl_id, link_id,cat_id
on my extraTBL I have: id, link_id, value
How do I do a single query to select from tempTBL all items where isinsrted = 0 then insert them to linksTBL and for each record inserted, pickup ID (which is primary) and then insert that ID to categoryTBL with cat_id = 88. after that insert extraTBL ID for link_id and url for value.
I know this is so confusing, put I'll post this anyhow...
This is what I have so far:
INSERT IGNORE INTO linksTBL (link_id,link_name,alias)
VALUES(NULL,'tex2','hello'); # generate ID by inserting NULL
INSERT INTO categoryTBL (link_id,cat_id)
VALUES(LAST_INSERT_ID(),'88'); # use ID in second table
I would like to add here somewhere that it only selects items where isinserted = 0 and iserts those records, and onse inserted, will change isinserted to 1, so when next time it runs, it will not add them again.
i am connecting to a mysql database through excel using odbc
what does this line do?
Set rs = oConn.Execute("SELECT @@identity", , adCmdText)
i am having trouble updating the database:
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("datapath") = dpath
.Fields("analysistime") = atime
.Fields("reporttime") = rtime
.Fields("lastcalib") = lcalib
.Fields("analystname") = aname
.Fields("reportname") = rname
.Fields("batchstate") = "bstate"
.Fields("instrument") = "NA"
.Update ' stores the new record
End With
it is ONLY updating .Fields("instrument") = "NA", but for all other fields it is putting NULL values
Hi ,
I have created Dealer dimension in SSAS 2005 and it has 3 hierarchies. By default the hierarchy created first is the default hierarchy of the dimension.
Is there any way to change the default hierarchy to another hierarchy.
I'm using sqlobject in Python. I connect to the database with
conn = connectionForURI(connStr)
conn.makeConnection()
This succeeds, and I can do queries on the connection:
g_conn = conn.getConnection()
cur = g_conn.cursor()
cur.execute(query)
res = cur.fetchall()
This works as intended. However, I also defined some classes, e.g:
class User(SQLObject):
class sqlmeta:
table = "gui_user"
username = StringCol(length=16, alternateID=True)
password = StringCol(length=16)
balance = FloatCol(default=0)
When I try to do a query using the class:
User.selectBy(username="foo")
I get an exception:
...
File "c:\python25\lib\site-packages\SQLObject-0.12.4-py2.5.egg\sqlobject\main.py", line 1371, in selectBy
conn = connection or cls._connection
File "c:\python25\lib\site-packages\SQLObject-0.12.4-py2.5.egg\sqlobject\dbconnection.py", line 837, in __get__
return self.getConnection()
File "c:\python25\lib\site-packages\SQLObject-0.12.4-py2.5.egg\sqlobject\dbconnection.py", line 850, in getConnection
"No connection has been defined for this thread "
AttributeError: No connection has been defined for this thread or process
How do I define a connection for a thread? I just realized I can pass in a connection keyword which I can give conn to to make it work, but how do I get it to work if I weren't to do that?
I need a shell script that deletes 1000 rows from a massive database until it is done.
It is very simple, but i am very weak in shell scripting, and the many tutorials online offer extremely similar, but different nuances in syntax
I have a MySQL query which gets including some vars like that:
messages TABLE receiver cols
user1 rows : 1,3,5
user2 rows : 2,3
user3 rows : 1,4
I want to get rows which includes '3' value. So I will get 'user1' and 'user2'.
I tried that but naturally it doesn't work.
mysql_query("SELECT * FROM messages WHERE receiver='3'");
How can I do this?
I have a table with products, their amount and their price. I need to select all entries where the average price per article is between a range.
My query so far:
SELECT productid,AVG(SUM(price)/SUM(amount)) AS avg FROM stock WHERE avg=$from AND avg<=$to GROUP BY productid
If do this, it tells me avg doesnt exist.
Also i obviously need to group by because the sum and average need to be per wine
I'm looking at building a facility which allows querying for data with hierarchical filtering. I have a few ideas how I'm going to go about it but was wondering if there are any recommendations or suggestions that might be more efficient.
As an example imagine that a user is searching for a job. The job areas would be as follows.
1: Scotland
2: --- West Central
3: ------ Glasgow
4: ------ Etc
5: --- North East
6: ------ Ayrshire
7: ------ Etc
A user can search specific (ie Glasgow) or in a larger area (ie Scotland).
The two approaches I am considering are
1: keep a note of children in the database for each record (ie cat 1 would have 2, 3, 4 in its children field) and query against that record with a SELECT * FROM Jobs WHERE Category IN Areas.childrenField.
2: Use a recursive function to find all results who have a relation to the selected area
The problems I see from both are
1: holding this data in the db will mean having to keep track of all changes to structure
2: Recursion is slow and inefficent
Any ideas, suggestion or recommendations on the best approach? I'm using C# ASP.NET with MSSQL 2005 DB.
I've been reading a lot about the disadvantages of using "order by rand" so I don't need update on that.
I was thinking, since I only need a limited amount of rows retrieved from the db to be randomized, maybe I should do:
$r = $db->query("select * from table limit 500");
for($i;$i<500;$i++)
$arr[$i]=mysqli_fetch_assoc($r);
shuffle($arr);
(i know this only randomizes the 500 first rows, be it).
would that be faster than
$r = $db->("select * from table order by rand() limit 500");
let me just mention, say the db tables were packed with more than...10,000 rows.
why don't you do it yourself?!? - well, i have, but i'm looking for your experienced opinion.
thanks!
I try to filter a phrase to make a search in my website i've this query, this code working with one word but when i type wit more than one isn't working becuase the print is without spaces.
$phrase = $this->getState($this->context.".filter_phrase");
printf("Original string: %s\n", $phrase);
if(!empty($phrase)) {
$escaped = $db->escape($phrase, true);
printf("Escaped string: %s\n", $escaped);
$quoted = $db->quote("%" . $escaped . "%" , false);
$query->where ('a.title LIKE ' .$quoted);
}
Example i type king and the output is king , when i type the king the output is theking, i want to know if exist any way to conserve the blank spaces.