Terminating a Long Query

Hi there!

Have anyone taken the “Terminating a Long Query” part of the SQL for Data Analysis course?

I’m having a trouble with this part with the 2 last questions especially.
I’m trying to identify the process ID of the sleep query with the following code:
select pid, query from pg_stat_activity where state = 'active'; but it’s doesn’t look it’s working out.

Do you have any ideas?

Also, I tried the 3rd questions which is ask us to force the sleep command using the pg_terminate_background, but I can not make it neither:
select pg_terminate_background(1663);
It said that there is no functions matches the giver and name argument…

I hope you could give me a clue!! :slight_smile:

Thanks a lot!!

Hey Jacques,

It’s very strange that the second question is not passing for you - that is the correct query. Is there any chance you are copy/pasting in the answer? If so, can you please refresh the page and try entering the command manually?

The third question has a typo! The function should be pg_terminate_backend. I’ve gone in and fixed that now. Thanks for bringing this to our attention :slight_smile:


Hi Lorraine,

I hope you’re doing good!
Thanks for your reply. I just tried the exercise again. I made the question 3 and it’s working! Unfortunately, I’m still having trouble with the question number 2.

Is the answer below correct?
select pid, query from pg_stat_activity where state = 'active';

Have a good one! :slight_smile: