1

I have been trying to import a .sql file to my pgAdmin 4 since 2 hours now. I have a Windows and PostgreSQL 14.

I realized I approached correctly since I was able to import a small (2KB) file (through drag and drop or through the 'Open File' menubar. However, if I want to do the same for my 160GB .sql file it does not work. Any suggestions what I can do?

asked Nov 10, 2021 at 19:42
5
  • 1
    I've never known pgAdmin4 to do anything through drag and drop, nor for it to have an "Open file" menu bar in the first place. Where are dropping the files, and where are you finding the Open file menubar? Commented Nov 10, 2021 at 21:56
  • When you say "it does not work", what actually happens? Does it time out? 160 GB might take a substantial time to import, depending upon the speed of your system and what features are being imported. Personally I'd be inclined to used psql to import a large file. Commented Nov 10, 2021 at 22:11
  • @jjanes I can drag and drop the small SQL file into the query editor, but this is not the case for the large file. The 'Open File' option is the second option in the menubar under 'Dashboard' when the query editor is open. But apart from these facts, do you know how to import such big files to pgAdmin4? Commented Nov 10, 2021 at 22:43
  • @hmallett it does not time out it says that it is loading but this notification just disappears after like 2 mins and nothing happens. That is literally my problem. Nothing happens when I import. The sql file is no where to find. (Btw the sql file is a large data set) Commented Nov 10, 2021 at 22:45
  • Yes, the "query editor" will try to read the whole file into memory, I wouldn't expect that to work with 160GB file. I thought there was an option to run a script without loading it memory, but can't find it now. Maybe with the addition of PSQL tool they thought you would use that instead. Commented Nov 13, 2021 at 20:15

1 Answer 1

2

I'd say that pgAdmin is the wrong tool for that. Do you really want to load an 160GB file into your query tool window?

Use psql, which is installed on your system, on the command line:

psql -h server_name -p 5432 -U dbuser -d dbname -f script.sql
answered Nov 11, 2021 at 2:51
4
  • Sadly that does not work 'psql' is not recognized as an internal or external command, operable program or batch file. Commented Nov 11, 2021 at 7:50
  • Sure that works. Either put the PostgreSQL binary directory in your PATH, or use an absolute path: "C:\Program Files\.....\bin\psql.exe" -h server_name ... (fill in the missing parts). Commented Nov 11, 2021 at 8:09
  • @josh: that error has nothing to do with Postgres. You need to setup your environment correctly. See here for some solutions Commented Nov 11, 2021 at 9:44
  • Hi I tried this command line process also but its taking for me around one day but still while checked the database its showing me the countrows as 18 mb Commented Jul 26, 2023 at 9:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.