I want to create a alert rule if a query on my SQL database takes longer than XXX seconds.
In the create alert dialog i cannot select a signal named "Duration".
Can you suggest a solution how to create a alert for a query taking longer than X seconds?
Related
Oracle version 12.1.0.2.0.
Toad version 12.1.0.22
I have a Table_A with 2 columns (A NUMBER, B NUMBER). Table_A is a new object created for a datafix. No application live objects are referring this.
Due to logic issue, an insert statement initiated a transaction to insert billions of record into the table_A. I found it mid way, killed the Oracle session with help of DBAs. Now the session is killed and I do not see them using session browser in Toad. It took almost 4 hours for the killed session to be removed from session browser. The killed session was available in session browser for the 4 hours with Status as Killed. I believe it must be rolling back the data.
Current Problem:
If I select (without hint) Table_A from my Oracle user account I'm either getting below ora error or the select runs forever (it kept running for more than 30 minutes, so I stopped the execution)
ORA-02395: exceeded call limit on IO usage
If I select with hint, it returns 0 rows.
Select /*+parallel(4)*/ *
from table_A;
Question:
Whether Killed session have any issues and running some IO in background ? I have no clue why the select statement (without hint) is running longer to return 0 rows. As this happened in prod system, I'm worried if any background process would cause any issue in coming days.
Apologies, I do not have DBA privileges to check locks or background running processed. If I missed to provide any additional info, please let me know. Thank you in advance for your time in responding back.
AS this happened in Production system, I do not have access to much of oracle v$ or metadata tables. I tried using session browser to find locks, background process but none helped
select *
from table_A;
I expect it to return 0 rows without a delay.
I want to make a stored procedure by which a Triggers will automatically execute after 5 seconds to check/show whether new row is updated or not.
I have a table called 'Inbox' in Database. I made a trigger for this whenever data in inserted in table.
CREATE TRIGGER tr_Inbox_ForInsert
ON Inbox
FOR INSERT
AS
BEGIN
SELECT * FROM inserted
END
I just want this trigger to execute itself after 5 seconds
That's not how triggers work... They are run after a transaction is carried out on the object they are attached to.
If you want something to run every X time interval, look into SQL Server Agent Jobs instead
I'm rather new to SQL Server, but I am working on an app where a record is added to a table, and is given a DateTime stamp.
I want to be able to dynamically update the Status column of this row, 1 hour after the row was added.
Is this possible without running some server side script or store procedure every couple minutes? Is there an efficient way to accomplish this?
In Sql Server you can have Time Dependant or Action Dependent code execution.
Time Dependent
Time Dependant Code execution is handled via SQL Server Agent Jobs. You can execute a stored procedure or ad-hoc T-SQL code on a certain time of the day. It can be scheduled to execute on regular basis.
Action Dependent
Action Dependent Code execution is handled via Triggers (After/Instead of Triggers). A piece of code that is executed in response to a DML action INSERT, UPDATE or DELETE.
Solution
In your case you are trying to execute code in response to an action (Insert) after a certain period of time. I dont think there is an efficient way of doing it I would rather do the following....
You can have a Column called Created of Datetime datatype in your table and set a default value of GETDATE().
Now you dont need the status column. All you need is a query/View which will check at runtime if the row was added more than an hour ago and will return it STATUS as required.
Something like.....
CREATE VIEW dbo.vw_Current_Status
AS
SELECT *
, CASE WHEN DATEDIFF(MINUTE, Created, GETDATE()) >= 60
THEN 'OLD'
ELSE 'New' END AS [Status]
FROM TABLE_NAME
I have a SQL Server 2008 R2 Enterprise database with a view on it called vw_Users.
-Running (Select * from vw_users) takes less than a second to complete.
-Running the SQL inside of the view takes less than a second to complete.
-Running (drop view vw_Users) just hangs and never actually completes. I let it run for about 10 minutes before I cancelled it.
I restarted the SQL Server Agent, then tried again, but it's still occurring.
This is a brand new issue, this server and this database have been running fine for over a year.
There are no indices on the view. I'm not sure what the problem is, but any help would be very appreciated.
Thanks
Someone or something has an open connection accessing that view and you are being blocked.
You can check this by starting your DROP, then in another window in SSMS running:
sp_who2 active
You should see a row with your spid, and the blocked_by field will have another spid number in it. Find that spid to see what is blocking you.
If it can be safely terminated, either close the process manually or from within SSMS run:
kill x
...where x is the spid of the blocking process.
Dear Sir,
I create a login form in which if you insert password 3 times wrong then u r account is locked for next 15 minute.
and we send a random password on referenced emailid which is sent after 15 minute.
For these 15 minute the account isactive='false'.
So can u please help me to give code for a stored procedure or triggers which is fired after 15 minute,which update this account isactive = 'true'.
Please help me.
Thanks In Advance
You wouldn't use a trigger for this. It might be possible to do something with service broker (I'm not sure).
The simplest way of doing it would be to just have a non nullable LockedOutUntil smalldatetime column in the Users table (defaulting to a date in the past) and have your code check that
isactive='true' or LockedOutUntil<getdate()
This would consume 4 bytes per row for all users though and presumably at any one time very few will be locked out so a more space efficient way would be to create a new table containing lockout details. Either your code would need to check this table to determine if the user is locked out or you could deactivate the user up front and have a SQL Server Agent job scheduled to run every minute to reactivate users whose lockout period had expired. The job could also delete these from the lockout table unless you wanted to maintain a history of these events.