PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 21st, 2012, 02:27 PM
Kalimoor Kalimoor is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 1 Kalimoor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m 3 sec
Reputation Power: 0
\timing in PL/pgSQL language in SQL file

Hi, I know how timing work in postgresql prompt, how I do is to type \timing.

However, I have created a sql file that is based on PL/pgSQL language, for example, the sql file looks like the following,

CREATE OR REPLACE FUNCTION make_plpgsql()
RETURNS VOID
LANGUAGE SQL
AS $$
CREATE LANGUAGE plpgsql;
$$;

for loop on some tables

\timing <----------------------- gives me error
for loop on some tables...
\timing

$$LANGUAGE plpgsql;



The error is like the following,

psql:test.sql:78: ERROR: syntax error at or near "\"
LINE 39: \timing
^

How do I make timing work in PL/pgSQL language in SQL file? Thank you.

Reply With Quote
  #2  
Old March 21st, 2012, 02:47 PM
shammat shammat is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Oct 2003
Location: Germany
Posts: 2,683 shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 3 Days 19 h 18 m 19 sec
Reputation Power: 284
Quote:
Originally Posted by Kalimoor
Hw do I make timing work in PL/pgSQL language in SQL file? Thank you.
You can't \timing is a psql (only) command and does not work inside a function.

You need to do the timing when using the function in psql, basically something like this:

Code:
postgres=> \timing
Timing is on
postgres=>select make_plpgsql();
..
..
Time: xx ms
postgres=>

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > \timing in PL/pgSQL language in SQL file

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap