빠른 시작: Visual Studio Code에서 PostgreSQL 확장용 GitHub Copilot 구성(미리 보기)

Visual Studio Code 대한 PostgreSQL 확장에는 GitHub Copilot 통합이 포함되어 AI 지원 개발을 통해 데이터베이스 워크플로를 향상합니다. PostgreSQL 데이터베이스에 연결되면 Copilot 라이브 연결에서 컨텍스트 정보에 액세스합니다. 이 액세스를 통해 @pgsql Copilot Chat 참가자는 정확하고 스키마 인식 SQL 쿼리 및 인사이트를 생성하여 개발을 간소화하고 Visual Studio Code 내에서 컨텍스트 전환을 최소화할 수 있습니다.

@pgsql participant는 다음을 포함해 확장이 연결할 수 있는 모든 데이터베이스에서 작동합니다.

  • Azure HorizonDB 클러스터.

HorizonDB 클러스터에 연결된 경우 Copilot 데이터베이스에 설치된 HorizonDB 관련 확장(예: pgvector, pg_diskann, azure_aiage)을 인식하고 이를 활용하는 프롬프트 및 SQL을 생성할 수 있습니다.

사전 요구 사항

시작하기 전에 적절한 도구와 리소스를 다운로드하여 설치했는지 확인합니다.

GitHub Copilot 및 GitHub Copilot 채팅 확장 설치

Visual Studio Code에 GitHub Copilot 확장이 아직 설치되어 있지 않은 경우:

  1. Visual Studio Code에서 확장 아이콘을 선택하고 GitHub Copilot를 검색한 다음 설치를 선택합니다.
  2. GitHub Copilot 채팅 확장은 GitHub Copilot와 함께 자동으로 설치됩니다.

Visual Studio Code에서 GitHub에 로그인

  1. GitHub 계정과 활성 GitHub Copilot 구독이 있는지 확인합니다.
  2. Visual Studio Code에서 GitHub Copilot을 사용하려면 Account 아이콘을 선택한 다음 GitHub로 로그인을 선택하세요.

GitHub Copilot을 시작하는 방법

PostgreSQL Visual Studio Code 확장과 함께 GitHub Copilot 사용을 시작하는 단계를 수행합니다.

  1. 개체 탐색기에서 PostgreSQL 데이터베이스를 마우스 오른쪽 단추로 클릭한 다음 이 데이터베이스와 채팅을 선택합니다. 로컬 PostgreSQL 또는 Azure HorizonDB와 같은 모든 연결에서 작동합니다.
  2. 메시지가 표시되면 GitHub Copilot가 데이터베이스 연결 컨텍스트에 액세스할 수 있도록 허용 을 선택합니다.
  3. Copilot 채팅 인터페이스가 열리면 접두사를 사용하여 @pgsql PostgreSQL 데이터베이스와 상호 작용하도록 지정하여 질문하기 시작합니다.

다음과 같은 프롬프트를 사용해 보세요.

@pgsql tell me about the tables in the HR schema

Copilot은 데이터베이스 스키마의 테이블에 대한 자세한 설명으로 응답합니다.

오른쪽 HorizonDB 엔드포인트에 연결

Azure HorizonDB 클러스터는 두 개의 엔드포인트를 제공하므로 채팅을 시작한 연결에 따라 Copilot이 생성한 SQL이 어느 엔드포인트에서 실행될지가 결정됩니다:

  • 읽기/쓰기 엔드포인트 - Copilot이 데이터 또는 스키마를 변경하거나, 가장 최근에 커밋된 상태를 읽어야 하는 문을 작성, 수정 또는 실행하도록 하려는 경우 이 연결을 사용하세요.
  • Reader 엔드포인트 - HA 복제본 전체에 걸쳐 부하 분산된 스케일 아웃의 이점을 활용하는 읽기 전용 쿼리(예: 탐색적 분석 또는 보고 프롬프트)를 Copilot이 작성하고 실행하도록 하려는 경우 이 연결을 사용합니다.

판독기 엔드포인트에 연결된 동안 Copilot 쓰기 문을 생성하는 경우 실행을 승인하기 전에 활성 연결을 읽기/쓰기 엔드포인트로 전환합니다.

읽기 및 쓰기 기능 사용

Visual Studio Code PostgreSQL 확장에 대한 GitHub Copilot 통합은 읽기 및 쓰기 작업을 모두 지원합니다. 라이브 연결 컨텍스트를 고려하는 AI 기반 제안을 사용하여 편집기에서 직접 데이터를 쿼리하고, 스키마를 수정하고, 레코드를 업데이트할 수 있습니다.

메모

PostgreSQL에 대한 GitHub Copilot Chat 통합은 데이터베이스를 변경할 수 있습니다. 특히 스테이징 및 프로덕션 환경에서는 주의해서 이 기능을 사용합니다. 생성된 SQL 코드를 실행하기 전에 항상 검토하고 안전한 환경에서 먼저 테스트하는 것이 좋습니다. 또한 Azure HorizonDB에서 쓰기 작업이 read/write 엔드포인트 대상으로 지정하는지 확인합니다. 판독기 엔드포인트는 읽기 전용입니다.

고급 프롬프트를 사용해 보세요.

@pgsql convert the hr.employees table to use a JSONB column for the address field

부조종사에서 SQL 제안에 응답하고 변경 권한을 요청할 수 있습니다.

실행을 승인하려면 다음을 수행합니다.

@pgsql Yes, please make the JSONB column for me

그런 다음 코필로트는 확인을 요청합니다.

@pgsql Yes, I confirm

상황에 맞는 메뉴 옵션 사용

편집기에서 SQL 코드를 선택하고 마우스 오른쪽 단추를 클릭하여 쿼리 설명, 쿼리다시 쓰기 또는 쿼리 성능 분석과 같은 GitHub Copilot 상황에 맞는 메뉴 옵션에 액세스할 수 있습니다. HorizonDB에서 설명 및 다시 쓰기 제안은 HorizonDB 관련 인덱스(예: pg_diskann 벡터 인덱스)가 있을 때도 고려됩니다.

기타 아이디어 및 프롬프트 레시피

다음 섹션에서는 데이터베이스 컨텍스트 및 개발 환경에 맞게 수정하거나 시도할 수 있는 개념 프롬프트를 보여 줍니다.

쿼리 최적화

이러한 프롬프트를 사용하여 특정 쿼리 최적화 문제를 해결하는 Copilot를 안내합니다.

I'm working on optimizing my database for high-concurrency workloads. The table is called transactions with millions of records, and I'm experiencing deadlocks under a heavy load. Help me optimize my table schema and queries.

I need help writing a query. The data is stored in the orders table, which uses the columns customer_id, order_date, and total_price. I also need to include a rolling 3-month average of customer spending using a window function.

I'm getting this error: 'ERROR: column "orders.total_price" must appear in the GROUP BY clause or be used in an aggregate function.'

성능 최적화

이러한 프롬프트를 사용하여 코필로트가 특정 성능 최적화 문제를 해결하도록 안내합니다.

Provide the Explain Plan for my most recent query, and please explain each step.

Can you run some performance metrics on my database and tell me how it performs?

My orders table has 10 million records, and queries on customer_id and order_date are slow. How can I optimize indexing, partitioning, and schema design for performance?

앱 개발

이러한 프롬프트를 사용하여 앱 개발 문제를 해결하는 Copilot를 안내합니다.

Generate a FastAPI endpoint to fetch orders from the ecom.orders table with pagination.

Generate an ETL pipeline script to clean and normalize the customer table data.

Generate a FastAPI project with my database using SQLAlchemy.

Azure HorizonDB의 AI 워크로드

HorizonDB 클러스터에 연결되어 있으면 Copilot을 사용하여 HorizonDB의 AI 기능인 pgvector, pg_diskann(고급 필터링 포함), 그리고 AI 모델 관리(제한된 미리 보기) 또는 사용자 고유의 Microsoft Foundry 배포를 기반으로 하는 azure_ai AI 함수를 구축할 수 있습니다.

@pgsql Create a products table with a description column and a vector(1536) embedding column. Then write a query that populates the embedding column for any rows where it's NULL using azure_openai.create_embeddings with the default-embedding managed model.

@pgsql Build a pg_diskann index on the products.embedding column using vector_cosine_ops, then write a similarity search that finds the top 10 products with average_rating > 4.5 and price between 100 and 200 - using DiskANN Advanced Filtering so the WHERE clause is evaluated during the vector search.

@pgsql Use azure_ai.extract() to pull product and sentiment out of the review_text column of the product_reviews table, and azure_ai.is_true() to flag reviews that mention shipping issues.

@pgsql I have a Microsoft Foundry deployment of gpt-5 in my own subscription. Show me how to register it with model_registry.model_add as 'gpt-5-byom' and then call azure_ai.generate() with that alias to rewrite the comment_text column of user_comments to be more polite.

읽기 확장

HorizonDB 클러스터의 reader 엔드포인트에 연결되면 부하 분산된 HA 복제본을 활용하는 읽기 전용 워크로드의 초안을 작성해 달라고 Copilot에게 요청할 수 있습니다.

@pgsql Generate a reporting query against the orders and customers tables that aggregates monthly revenue by region and customer segment. Make sure the query is read-only so it's safe to run against the HorizonDB reader endpoint.

정리

원활한 환경을 보장하려면 이 빠른 시작 중에 만든 임시 리소스 또는 구성을 정리합니다. 다음은 그 예입니다.

  • Visual Studio Code의 PostgreSQL 데이터베이스에서 연결을 끊습니다.
  • 세션 중에 만든 모든 테스트 데이터베이스, 테이블 또는 인덱스(인 pg_diskann 덱스 포함)를 제거합니다.
  • 불필요한 리소스 사용을 방지하기 위해 열려 있는 연결을 닫습니다.

피드백 및 지원

버그, 기능 요청 및 문제의 경우 Visual Studio Code의 기본 제공 피드백 도구를 사용합니다. Visual Studio Code 도움말 메뉴 또는 PGSQL 명령 팔레트를 통해 이 피드백을 완료할 수 있습니다.

  • 도움말 메뉴
    • 도움말 > 보고서 문제로 이동
  • 명령 팔레트
    • 명령 팔레트 Ctrl + Shift + P 를 열고 다음을 실행합니다. PGSQL: Report Issue