SQLServer2008存储结构详解:GAM, SGAM, PFS, IAM, DCM, BCM与区划分

需积分: 15 5 下载量 155 浏览量 更新于2024-07-31 收藏 577KB DOC 举报
本文档系列深入探讨了SQL Server 2008的存储结构,特别是关于GAM (Growable Allocation Map)、SGAM (System Global Area Map)、PFS (Page File Stream)、IAM (Index Allocation Map)、DCM (Data Compressed Memory) 和 BCM (Buffer Cache Management) 的相关内容。 首先,文章从数据库的基础概念出发,介绍了一个数据库是由用户定义的空间组成,这些空间用于持久存储对象,如数据库管理信息、表和索引。SQL Server 2008中的数据存储在操作系统文件中,包括行数据文件(存放数据对象)和日志文件(记录数据变更)。 数据库的基本存储单元是页,每页大小为8KB,逻辑上连续且编号。通过数据库ID、文件ID和页码,可以定位到任何一个数据页。SQL Server 2008的存储空间管理基于区(extents),一个区由8个连续页面组成,提供64KB的空间。区分为两种类型:统一区和混合区,前者为单个对象专用,后者可被多个对象共享,确保空间效率。 PFS(Page File Stream)在文件管理中扮演关键角色,它是日志文件的一部分,负责持久化更改数据页的事务日志。IAM则是索引页的分配地图,用于跟踪索引数据的分布,以便于快速访问。 DCM (Data Compressed Memory) 是SQL Server 2008引入的新特性,利用压缩技术存储数据,提高存储效率,减少I/O操作。BCM (Buffer Cache Management) 则是内存管理的核心部分,它负责缓存经常访问的数据,以提升查询性能。 整个文档系列深入剖析了SQL Server 2008如何组织和管理其存储结构,通过理解这些关键概念,数据库管理员可以更好地优化存储策略,确保系统的高效运行。理解GAM和SGAM的工作原理,以及不同区域类型的选择,对于优化数据库设计和性能至关重要。

优化这段代码 for j in n_components: estimator = PCA(n_components=j,random_state=42) pca_X_train = estimator.fit_transform(X_standard) pca_X_test = estimator.transform(X_standard_test) cvx = StratifiedKFold(n_splits=5, shuffle=True, random_state=42) cost = [-5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15] gam = [3, 1, -1, -3, -5, -7, -9, -11, -13, -15] parameters =[{'kernel': ['rbf'], 'C': [2x for x in cost],'gamma':[2x for x in gam]}] svc_grid_search=GridSearchCV(estimator=SVC(random_state=42), param_grid=parameters,cv=cvx,scoring=scoring,verbose=0) svc_grid_search.fit(pca_X_train, train_y) param_grid = {'penalty':['l1', 'l2'], "C":[0.00001,0.0001,0.001, 0.01, 0.1, 1, 10, 100, 1000], "solver":["newton-cg", "lbfgs","liblinear","sag","saga"] # "algorithm":['auto', 'ball_tree', 'kd_tree', 'brute'] } LR_grid = LogisticRegression(max_iter=1000, random_state=42) LR_grid_search = GridSearchCV(LR_grid, param_grid=param_grid, cv=cvx ,scoring=scoring,n_jobs=10,verbose=0) LR_grid_search.fit(pca_X_train, train_y) estimators = [ ('lr', LR_grid_search.best_estimator_), ('svc', svc_grid_search.best_estimator_), ] clf = StackingClassifier(estimators=estimators, final_estimator=LinearSVC(C=5, random_state=42),n_jobs=10,verbose=0) clf.fit(pca_X_train, train_y) estimators = [ ('lr', LR_grid_search.best_estimator_), ('svc', svc_grid_search.best_estimator_), ] param_grid = {'final_estimator':[LogisticRegression(C=0.00001),LogisticRegression(C=0.0001), LogisticRegression(C=0.001),LogisticRegression(C=0.01), LogisticRegression(C=0.1),LogisticRegression(C=1), LogisticRegression(C=10),LogisticRegression(C=100), LogisticRegression(C=1000)]} Stacking_grid =StackingClassifier(estimators=estimators,) Stacking_grid_search = GridSearchCV(Stacking_grid, param_grid=param_grid, cv=cvx, scoring=scoring,n_jobs=10,verbose=0) Stacking_grid_search.fit(pca_X_train, train_y) var = Stacking_grid_search.best_estimator_ train_pre_y = cross_val_predict(Stacking_grid_search.best_estimator_, pca_X_train,train_y, cv=cvx) train_res1=get_measures_gridloo(train_y,train_pre_y) test_pre_y = Stacking_grid_search.predict(pca_X_test) test_res1=get_measures_gridloo(test_y,test_pre_y) best_pca_train_aucs.append(train_res1.loc[:,"AUC"]) best_pca_test_aucs.append(test_res1.loc[:,"AUC"]) best_pca_train_scores.append(train_res1) best_pca_test_scores.append(test_res1) train_aucs.append(np.max(best_pca_train_aucs)) test_aucs.append(best_pca_test_aucs[np.argmax(best_pca_train_aucs)].item()) train_scores.append(best_pca_train_scores[np.argmax(best_pca_train_aucs)]) test_scores.append(best_pca_test_scores[np.argmax(best_pca_train_aucs)]) pca_comp.append(n_components[np.argmax(best_pca_train_aucs)]) print("n_components:") print(n_components[np.argmax(best_pca_train_aucs)])

2023-07-14 上传