Database Administrators
Q&A for database professionals who wish to improve their database skills
Latest Questions
0
votes
1
answers
2523
views
"undefined function pg_pconnect()" when connecting to Postgres from CodeIgniter
I just installed Postgresql and pgadmin in my Ubuntu system. I can create a database from the pgadmin interface and everything seems ok, but when I try to connect to the database from my CodeIgniter application it cannot not connect. It shows an error like: An uncaught Exception was encountered > Ty...
I just installed Postgresql and pgadmin in my Ubuntu system. I can create a database from the pgadmin interface and everything seems ok, but when I try to connect to the database from my CodeIgniter application it cannot not connect. It shows an error like:
An uncaught Exception was encountered
> Type: Error
>
> Message: Call to undefined function pg_pconnect()
>
> Filename: /my codeigniter application
> path/system/database/drivers/postgre/postgre_driver.php
My database configuration is:
$db['postgres_db'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'postgres',
'password' => '1234',
'database' => 'finance',
'dbdriver' => 'postgre',
'dbprefix' => '',
'pconnect' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE,
'port' => 5432
);
How can I resolve this problem?
jpsai
(1 rep)
Jun 28, 2018, 10:13 AM
• Last activity: Jun 18, 2025, 09:10 AM
1
votes
1
answers
1094
views
MySQL query takes too long in codeigniter
I've made this query SELECT id,name,iupac_name,inchi_key,molecular_weight,molecular_formula,exact_molecular_mass FROM compound WHERE name LIKE '%quer%' OR iupac_name LIKE '%quer%' OR inchi_key LIKE '%quer%' OR inchi_key IN( SELECT inchi_key FROM compound_synonyms WHERE name LIKE '%quer%') that took...
I've made this query
SELECT id,name,iupac_name,inchi_key,molecular_weight,molecular_formula,exact_molecular_mass
FROM compound
WHERE name LIKE '%quer%'
OR iupac_name LIKE '%quer%'
OR inchi_key LIKE '%quer%'
OR inchi_key IN( SELECT inchi_key FROM compound_synonyms WHERE name LIKE '%quer%')
that took 0.3563 seconds to show result through phpmyadmin in my local machine and took 0.1117 seconds in digital ocean vps.
But the same query took 24+ minutes in another vps.
Does anyone can help me to find out the problem?
morshed
(111 rep)
Jul 21, 2019, 05:03 AM
• Last activity: Dec 19, 2022, 06:00 AM
2
votes
1
answers
579
views
Optimize a query multiple tables & Multiple conditions
I need to optimize the query which has multiple joins. And also with multiple OR AND conditions which varies depending upon the user input. The query which gets generated is: SELECT emp.name as entryby, l.cname as location_name, sp.product AS product_name, sp.refcode as pro_refcode, sup.vendorname,...
I need to optimize the query which has multiple joins. And also with multiple OR AND conditions which varies depending upon the user input.
The query which gets generated is:
SELECT emp.name as entryby, l.cname as location_name, sp.product AS product_name,
sp.refcode as pro_refcode, sup.vendorname, sp.mrpgross AS mrpgross,
pro.cp AS cost_price, cust.name AS customer_names, cust.phone AS mobile_no,
sp.uom1 as TotalQTY, sp.category_name, auth.*
FROM erp_salesorderproductsdetails sp
LEFT JOIN erp_salesorder s ON s.id = sp.salesorder_id
LEFT JOIN geopos_employees emp ON emp.id = s.entryby
LEFT JOIN geopos_locations l ON s.loc = l.id
LEFT JOIN geopos_productall pro ON pro.product_code = sp.refcode
LEFT JOIN geopos_supplier sup ON sup.id = pro.vendor
LEFT JOIN geopos_customers cust ON cust.id = s.customer
LEFT JOIN authorize_po auth ON auth.salesorder_id = s.id
WHERE sp.salesorder_id = 301
AND ( sp.category_name IN(SPECTACLES, SPECTACLE LENSES) )
OR sp.salesorder_id = 310
AND ( sp.category_name IN(SPECTACLES, SPECTACLE LENSES) )
OR sp.salesorder_id = 3234
AND (sp.category_name IN(SPECTACLES, SPECTACLE LENSES) )
Here, the
sp.salesorder_id
along with AND in where condition can be multiple depending upon the users input.
To retrieve some 700 - 800 records it takes around 2 to 3.5 mins.
But mostly the data counts goes to over 2000. In that case its not performing very efficiently. Can anybody suggest anything ?
I have also shared the Explain result of the query being generated. However, sharing the Table structure won't be a good idea as some tables have columns more than 50.
1 SIMPLE sp ALL NULL NULL NULL NULL 6211 Using where
1 SIMPLE s eq_ref PRIMARY PRIMARY 4 erp_billing.sp.salesorder_id 1
1 SIMPLE emp eq_ref PRIMARY PRIMARY 4 erp_billing.s.entryby 1 Using where
1 SIMPLE l eq_ref PRIMARY PRIMARY 4 erp_billing.s.loc 1 Using where
1 SIMPLE pro ALL NULL NULL NULL NULL 340264 Using where; Using join buffer (flat, BNL join)
1 SIMPLE sup eq_ref PRIMARY PRIMARY 4 erp_billing.pro.vendor 1 Using where
1 SIMPLE cust eq_ref PRIMARY PRIMARY 4 erp_billing.s.customer 1 Using where
1 SIMPLE auth ALL NULL NULL NULL NULL 13 Using where; Using join buffer (flat, BNL join)
Parikshit Bharadwaj
(23 rep)
Aug 9, 2022, 07:14 PM
• Last activity: Aug 11, 2022, 07:09 AM
0
votes
1
answers
4352
views
Get the last ID after INSERT the PostgreSQL database with PgBouncer
Previously we used PostgreSQL 9 with PgBouncer in session mode, and with that was able to easily create a new record and get the last ID with `pg_get_serial_sequence` and `CURRVAL`. INSERT INTO "table" ("column") VALUES ('ABC'); SELECT pg_get_serial_sequence('table', 'tableid') AS seq; SELECT CURRVA...
Previously we used PostgreSQL 9 with PgBouncer in session mode, and with that was able to easily create a new record and get the last ID with
pg_get_serial_sequence
and CURRVAL
.
INSERT INTO "table" ("column") VALUES ('ABC');
SELECT pg_get_serial_sequence('table', 'tableid') AS seq;
SELECT CURRVAL('public.table_tableid_seq') AS ins_id;
But the use of the Session mode of PgBouncer proved to be extremely problematic for us, with several operations per second, the Pool easily reached the capacity of connections, so we switched to PostgreSQL 12 with PgBouncer in Transaction mode.
One problem that has begun to occur with this mode is that using operations that require being in the same session does not work, not allowing to use CURRVAL.
What is the best alternative to continue working in Transaction mode and get the ID after INSERT, without the risk of returning the ID generated by the same operation by another user?
An important detail is that we use a PHP Framework that does not allow to add an INSERT ... RETURNING
for each operation.
Tom
(438 rep)
Oct 21, 2020, 06:42 PM
• Last activity: Apr 13, 2022, 09:00 PM
-2
votes
2
answers
33
views
Codeignier---sql database
>[Microsoft][SQL Server Native Client 11.0][SQL Server]Column 'TantraBackup00.GuildName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. SELECT PK.KillerAccountName as CharacterName ,count(PK.KillerAccountName) as totalkillings , TB.G...
>[Microsoft][SQL Server Native Client 11.0][SQL Server]Column 'TantraBackup00.GuildName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
SELECT
PK.KillerAccountName as CharacterName
,count(PK.KillerAccountName) as totalkillings
, TB.GuildName
FROM PlayerKills as PK
LEFT JOIN
TantraBackup00 as TB ON PK.KillerAccountName = TB.CharacterName
WHERE
PK.KillerCharacterName !=''
GROUP BY PK.KillerAccountName
chirag jogani
(1 rep)
Apr 30, 2021, 10:11 AM
• Last activity: Apr 30, 2021, 12:19 PM
0
votes
1
answers
65
views
Azure database - unable to locate in my Azure account
I have an Azure account where a developer that used to work with me has set up an MSSQL database on an Ubuntu VM. The PHP (CodeIgniter) system I am working on logs in (so database queries work correctly). I have the following information available: * The connection string uses "sqlsrv" driver in Cod...
I have an Azure account where a developer that used to work with me has set up an MSSQL database on an Ubuntu VM.
The PHP (CodeIgniter) system I am working on logs in (so database queries work correctly). I have the following information available:
* The connection string uses "sqlsrv" driver in CodeIgniter
* The hostname in the CI config is "127.0.0.1".
* Using "top" command, I can see "sqlservr" using resources (12.8% mem, 0.7% CPU)
* I can run SQL scripts with "sqlcmd -S localhost"
But yet, I can't find anywhere where this database is listed in my Azure portal. Very frustrating. There is nothing listed under "SQL databases" and I have been through all the visible options in the Linux VM, and can't find it.
What am I missing?
Kobus Myburgh
(135 rep)
Sep 21, 2019, 01:39 PM
• Last activity: Sep 21, 2019, 01:51 PM
Showing page 1 of 6 total questions