PDA

View Full Version : Does anyone know how to run a REINDEX via command line?



Rivers
04-12-2010, 01:11 AM
Anyone know what the syntax is? I tried a couple but it doesn't seem to work. Trying to automate it by running a .bat file every weekend.

psql .. ?

netsrak
04-12-2010, 03:20 AM
If you activate it in pgadminII there is a message box which displays the command line. You can copy and paste it from there.

Rivers
04-12-2010, 03:30 AM
hmm i just tried it but i don't seem to be able to see the command line changing to show the reindex command?

netsrak
04-12-2010, 03:50 AM
You are right, seems like i used a different pgadmin version (i guess the linux version) when i saw the command line options.

Here are some links explaining how it should work:
Re: Reindex from command line linux (http://archives.postgresql.org/pgsql-admin/2005-04/msg00315.php)
PostgreSQL: Documentation: Manuals: PostgreSQL 8.3: REINDEX (http://www.postgresql.org/docs/8.3/static/sql-reindex.html)

Rivers
04-12-2010, 04:05 AM
Just tried both but to no avail..

Get an error: psql: FATAL: role -c does not exist

I tried using psql <mydbname> -c "reindex database" and quite a fair bit of others. :( nobody ever tried this out using command line and scheduling it?

netsrak
04-12-2010, 09:03 AM
if you run psql --help you should get a syntax help.
And there should also be a documentation for this on the postgresql site.

I can't test it in the moment but if you can't figure it out push this thread again and i will try it on my own

netsrak
04-12-2010, 09:47 AM
This is the easiest solution i think:


reindexdb -U postgres -w -d HoldemManager

-U the user to connect
-w don't ask for password
-d the database name

for further options type reindexdb --help

Rivers
04-12-2010, 09:57 AM
doesnt work.. i have to put a psql in front cos reindexdb isn't an executable in windows


C:\Windows\System32>psql reindexdb -U postgres -w HOLDEMMANAGER
psql: warning: extra command-line argument "postgres" ignored
psql: warning: extra command-line argument "-w" ignored
psql: warning: extra command-line argument "HOLDEMMANAGER" ignored
psql: FATAL: database "reindexdb" does not exist


the vacuumdb command line script works fine for me though

psql -h localhost -d HOLDEMMANAGER -U postgres -c "vacuum full"

when I try to edit the vacuum db script with "reindex database" it doesn't work. darn.

netsrak
04-13-2010, 03:25 AM
You need to have "reindexdb" in the postgresql\bin folder and start it from there

Rivers
04-13-2010, 09:15 AM
Thanks. That worked perfect!