473,652 Members | 2,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AUTOCOMMIT didn't work...


Hi,

Please see the history below...

Does AUTOCOMMIT as used here functionally replace VACUUM ANALYZE?

If I turn on AUTOCOMMIT is every transaction commited as it is
executed? If this is the case the query will take about twice as
long... I have actually tested this scenario.

Using AUTOCOMMIT as suggested didn't solve the problem.

Thanks again for your help!
Lynn Tilby
lt****@asu.edu

*************** *************** *************** *************** *************** ***

#include <stdlib.h>
#include <ctype.h>

EXEC SQL INCLUDE sqlca; /* include the sql debugging stuff... */

/********* !!!!!!!!!! POSTGRES SQL DEBUGGING STRUCTURE FIELDS ************/
#define DEBUG_SQL printf("sqlcaid = %s\n", sqlca.sqlcaid); printf("sqlabc =
%f\n", sqlca.sqlabc); printf("sqlcode = %f\n", sqlca.sqlcode);
printf("sqlca.s qlerrm.sqlerrml = %d\n", sqlca.sqlerrm.s qlerrml);
printf("sqlca.s qlerrm.sqlerrmc = %s\n", sqlca.sqlerrm.s qlerrmc); printf("sqlerrp
= %s\n", sqlca.sqlerrp); printf("sqlerrd = %f\n", sqlca.sqlerrd); printf("sqlext
= %s\n", sqlca.sqlext);

int main()
{

EXEC SQL BEGIN DECLARE SECTION; /* declare the variables used by sql */

EXEC SQL END DECLARE SECTION; /* declare the variables used by sql */

EXEC SQL CONNECT TO pma;
EXEC SQL WHENEVER sqlerror sqlprint; /* turn on verbose sql error ckg */

DEBUG_SQL
EXEC SQL SET AUTOCOMMIT = ON;
DEBUG_SQL
EXEC SQL VACUUM ANALYZE optn_cent_xref;
DEBUG_SQL
}

[lynn@polaris strdl_sim]$ make vrfy_prob
/usr/local/pgsql/bin/ecpg -I/usr/local/pgsql/include -o vrfy_prob.c vrfy_prob.cpg
gcc -g3 -I/usr/include/pgsql -o vrfy_prob -lm -lc -lecpg -lpq vrfy_prob.c
[lynn@polaris strdl_sim]$ make vrfy_prob
/usr/local/pgsql/bin/ecpg -I/usr/local/pgsql/include -o vrfy_prob.c vrfy_prob.cpg
gcc -g3 -I/usr/include/pgsql -o vrfy_prob -lm -lc -lecpg -lpq vrfy_prob.c
[lynn@polaris strdl_sim]$ ./vrfy_prob
sqlcaid = SQLCA Œ
sqlabc = -1.998680
sqlcode = -1.998680
sqlca.sqlerrm.s qlerrml = 0
sqlca.sqlerrm.s qlerrmc =
sqlerrp = NOT SET
sqlerrd = -1.998680
sqlext =
sqlcaid = SQLCA Œ
sqlabc = -1.998680
sqlcode = -1.998680
sqlca.sqlerrm.s qlerrml = 0
sqlca.sqlerrm.s qlerrmc =
sqlerrp = NOT SET
sqlerrd = -1.998680
sqlext =
sql error Postgres error: ERROR: VACUUM cannot run inside a BEGIN/END block
line 25.
sqlcaid = SQLCA Œ
sqlabc = -1.998680
sqlcode = -1.998681
sqlca.sqlerrm.s qlerrml = 76
sqlca.sqlerrm.s qlerrmc = Postgres error: ERROR: VACUUM cannot run inside a
BEGIN/END block
line 25.
sqlerrp = 25.
sqlerrd = -1.998680
sqlext =
[lynn@polaris strdl_sim]$
*************** *************** *************** *************** *************** ****
On Sat, Nov 15, 2003 at 11:31:08PM -0500, Bruce Momjian wrote:
I might be wrong on this but I think that ecpg using transactions by
default for each query.
Perhaps turning on autocommit?
Yep, use:

EXEC SQL SET AUTOCOMMIT = ON;


Or use 'ecpg -t'.

Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: me****@jabber.o rg
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Hello,

I might be wrong on this but I think that ecpg using transactions by
default for each query.
Perhaps turning on autocommit?

J
Ly********@asu. edu wrote:
The following program produces the output below...
It is built with:

vrfy_prob: vrfy_prob.cpg
/usr/local/pgsql/bin/ecpg -I/usr/local/pgsql/include -o vrfy_prob.c vrfy_prob.cpg gcc -g${DEBUG} -I/usr/include/pgsql -o vrfy_prob -lm -lc -lecpg -lpq vrfy_prob.c
I am not using a BEGIN/END block, though the error messages indicate
that I am.

How can I do a vacuum analyze from within embedded sql in a c program
that works?

Thanks for your help!

Lynn Tilby
lt****@asu.e du

************** *************** ** PROGRAM *************** *************** **
#include <stdlib.h>
#include <ctype.h>

EXEC SQL INCLUDE sqlca; /* include the sql debugging stuff... */

/********* !!!!!!!!!! POSTGRES SQL DEBUGGING STRUCTURE FIELDS ************/#define DEBUG_SQL printf("sqlcaid = %s\n", sqlca.sqlcaid); printf("sqlabc =%f\n", sqlca.sqlabc); printf("sqlcode = %f\n", sqlca.sqlcode);printf("sqlca. sqlerrm.sqlerrm l = %d\n", sqlca.sqlerrm.s qlerrml);
printf("sqlca. sqlerrm.sqlerrm c = %s\n", sqlca.sqlerrm.s qlerrmc); printf("sqlerrp= %s\n", sqlca.sqlerrp); printf("sqlerrd = %f\n", sqlca.sqlerrd); printf("sqlext= %s\n", sqlca.sqlext);

int main()
{

EXEC SQL BEGIN DECLARE SECTION; /* declare the variables used by sql */

EXEC SQL END DECLARE SECTION; /* declare the variables used by sql */

EXEC SQL CONNECT TO pma;
EXEC SQL WHENEVER sqlerror sqlprint; /* turn on verbose sql error ckg */

DEBUG_SQL
EXEC SQL VACUUM ANALYZE optn_cent_xref;
DEBUG_SQL
}

************** *************** ** OUTPUT *************** *************** **

[lynn@polaris strdl_sim]$ ./vrfy_prob
sqlcaid = SQLCA Œ
sqlabc = -1.998680
sqlcode = -1.998680
sqlca.sqlerrm. sqlerrml = 0
sqlca.sqlerrm. sqlerrmc =
sqlerrp = NOT SET
sqlerrd = -1.998680
sqlext =
sql error Postgres error: ERROR: VACUUM cannot run inside a BEGIN/END block line 23.
sqlcaid = SQLCA Œ
sqlabc = -1.998680
sqlcode = -1.998681
sqlca.sqlerrm. sqlerrml = 76
sqlca.sqlerrm. sqlerrmc = Postgres error: ERROR: VACUUM cannot run inside a
BEGIN/END block
line 23.
sqlerrp = 23.
sqlerrd = -1.998680
sqlext =
[lynn@polaris strdl_sim]$
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC - S/JDBC
Postgresql support, programming, shared hosting and dedicated hosting.
+1-503-222-2783 - jd@commandpromp t.com - http://www.commandprompt.com
PostgreSQL.Org - Editor-N-Chief - http://www.postgresql.org


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 12 '05 #1
1 2820
On Mon, 2003-11-17 at 20:39, Ly********@asu. edu wrote:
Hi,

Please see the history below...

Does AUTOCOMMIT as used here functionally replace VACUUM ANALYZE?
No; they are completely separate concepts. Autocommit treats every
statement as a separate transaction; as you have found, this will slow
things down.

VACUUM ANALYZE reads through all rows in a table or all the tables in a
database to set up some statistics to guide the planner. It needs to be
used regularly or the planner will start to produce invalid results and
queries will take a long time. That is not the same reason for taking a
long time as making every statement a separate transaction.
If I turn on AUTOCOMMIT is every transaction commited as it is
executed? If this is the case the query will take about twice as
long... I have actually tested this scenario.

Using AUTOCOMMIT as suggested didn't solve the problem.


I think someone said turn it on when he meant turn it off? It is always
on by default.

To put many statements into one transaction, enclose them all in BEGIN;
and END; They should then run a lot faster.
Oliver Elphick Ol************@ lfix.co.uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
=============== =============== ==========
"A Song for the sabbath day. It is a good thing to
give thanks unto the LORD, and to sing praises unto
thy name, O most High." Psalms 92:1
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3632
by: Marcus | last post by:
Hello, I have 2 questions regarding InnoDB tables: 1. In the MySQL manual, it states that "MySQL begins each client connection with autocommit mode enabled by default. When autocommit is enabled, MySQL does a commit after each SQL statement if that statement did not return an error." Does using BEGIN override this behavior? In other words, with
0
5298
by: jy2003 | last post by:
Below is what I got by using MySQL's --log startup option. The original Java(with JDBC driver) program that creates the queries at runtime was coded by other people, and unfortunately, they are not available to answer any question. My question is: Do we need so many "SET autocommit=1" at all? Bu default, MySQL always starts a new connection with autocommit enabled.(?dev.mysql.com/doc/mysql/en/InnoDB_and_.., do we need to do "SET...
0
2497
by: Scott Mills | last post by:
Hi all, I've got MySQL 4.1.3 installed on RH 7.3... everything's fine so far except for getting the init_connect string to work. I followed the instructions on http://dev.mysql.com/doc/mysql/en/Server_system_variables.html and added the below line to my '/etc/my.cnf' file under : init_connect='SET AUTOCOMMIT=0'
4
2657
by: Christian Traber | last post by:
Hi, thanks for the new great version! Only one small problem, how can I disable autocommit in Postgres 7.4 in libpgtcl and psql? I found something about .psqlrc but how is the syntax and how can I set it for libpgtcl? BTW, SET AUTOCOMMIT TO ON still gives no error, only SET AUTOCOMMIT TO OFF
1
4369
by: Carmen Gloria Sepulveda Dedes | last post by:
Hola. He instalado postgres 7.4, y vi que ya no es posible hacer un "alter database ... set autocommit = off" Leyendo la documentacion de 7.4, encontre lo siguiente: Note: The autocommit-on mode is PostgreSQL's traditional behavior, but autocommit-off is closer to the SQL spec. If you prefer autocommit-off, you may wish to set it in your .psqlrc file.
0
1659
by: Carmen Gloria Sepulveda Dedes | last post by:
Hello. I have installed postgres 7.4, and I see that it's not possible to do "alter database ... set autocommit = off" In the documentation, I found: Note: The autocommit-on mode is PostgreSQL's traditional behavior, but autocommit-off is closer to the SQL spec. If you prefer autocommit-off, you may wish to set it in your .psqlrc file.
1
2952
by: Matt Van Mater | last post by:
I'm looking to get a little more performance out of my database, and saw in the docs a section about disabling autocommit by using the BEGIN and COMMIT keywords. My problem is this: I enforce unique rows for all data, and occasionally there is an error where I try to insert a duplicate entry. I expect to see these duplicate entries and depend on the DB to enforce the row uniqueness. When I just run the insert statements without the...
33
13993
by: John Sidney-Woollett | last post by:
With the advent of postgres v8, would it be possible to change the default behaviour of psql from AUTOCOMMIT=ON to AUTOCOMMIT=OFF ? Although this might break backward compatibility, it might be acceptable on the basis that v8 is such a major release. Also adding a new command line parameter to control the AUTOCOMMIT setting for those users that will experience broken scripts executed (especially using the -c command) might help ease...
2
4169
by: Jia Lu | last post by:
Hi all. I use cx_Oracle to connect to an Oracle9i DB. And I want to turn on AUTOCOMMIT function. I see that cur.execute("SET AUTOCOMMIT ON") cannot work. Is there any method to do that ?? Thanks a lot!
0
8370
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8704
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8590
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4147
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2707
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.