一个Entity Framework Core的性能优化案例

概要

本文提供一个EF Core的优化案例,主要介绍一些EF Core常用的优化方法,以及在优化过程中,出现性能反复的时候的解决方法,并澄清一些对优化概念的误解,例如AsNoTracking并不包治百病。

本文使用的是Dotnet 6.0和EF Core 7.0。

代码及实现

背景介绍

本文主要使用一个图书和作者的案例,用于介绍优化过程。

  • 一个作者Author有多本自己写的的图书Book
  • 一本图书Book有一个发行商Publisher
  • 一个作者Author是一个系统用户User
  • 一个系统用户User有多个角色Role

本实例中Author表和Book数据量较大,记录数量全部过万条,其它数据表记录大概都是几十或几百条。具体实体类定义请见附录。

查询需求

我们需要查找写书最多的前两名作家,该作家需要年龄在20岁以上,国籍是法国。需要他们的FirstName, LastName, Email,UserName以及在1900年以前他们发行的图书信息,包括书名Name和发行日期Published。

基本优化思路

本人做EF Core的复杂查询优化,并不推荐直接查看生成的SQL代码,我习惯按照如下方式进行:

首先,进行EF的LINQ代码检查(初筛),找到明显的错误。

  1. 查看代码中是否有基本错误,主要针对全表载入的问题。例如EF需要每一步的LINQ扩展方法的返回值都是IQueryable类型,不能有IEnumerable类型;
  2. 查看是否有不需要的栏位;
  3. 根据情况决定是否加AsNoTracking,注意这个东西有时候加了也没用;

其次,找到数据量较大的表,进行代码整理和针对大数据表的优化(精细化调整)

  1. 在操作大数据表时候,先要进行基本的过滤;
  2. 投影操作Select应该放到排序操作后面;
  3. 减少返回值数量,推荐进行分页操作;

本人推荐一旦出现性能反复的时候或者代码整体基本完成的时候,再去查看生成的SQL代码。

初始查询代码

public  List<AuthorWeb> GetAuthors() {using var dbContext = new AppDbContext();var authors = dbContext.Authors.Include(x => x.User).ThenInclude(x => x.UserRoles).ThenInclude(x => x.Role).Include(x => x.Books).ThenInclude(x => x.Publisher).ToList().Select(x => new AuthorWeb{UserCreated = x.User.Created,UserEmailConfirmed = x.User.EmailConfirmed,UserFirstName = x.User.FirstName,UserLastActivity = x.User.LastActivity,UserLastName = x.User.LastName,UserEmail = x.User.Email,UserName = x.User.UserName,UserId = x.User.Id,RoleId = x.User.UserRoles.FirstOrDefault(y => y.UserId == x.UserId).RoleId,BooksCount = x.BooksCount,AllBooks = x.Books.Select(y => new BookWeb{Id = y.Id,Name = y.Name,Published = y.Published,ISBN = y.ISBN,PublisherName = y.Publisher.Name}).ToList(),AuthorAge = x.Age,AuthorCountry = x.Country,AuthorNickName = x.NickName,Id = x.Id}).ToList().Where(x => x.AuthorCountry == "France" && x.AuthorAge == 20).ToList();var orderedAuthors = authors.OrderByDescending(x => x.BooksCount).ToList().Take(2).ToList();List<AuthorWeb> finalAuthors = new List<AuthorWeb>();foreach (var author in orderedAuthors){List<BookWeb> books = new List<BookWeb>();var allBooks = author.AllBooks;foreach (var book in allBooks){if (book.Published.Year < 1900){book.PublishedYear = book.Published.Year;books.Add(book);}}author.AllBooks = books;finalAuthors.Add(author);}return finalAuthors;}

Benchmark测试后,系统资源使用情况如下:

在这里插入图片描述

代码性能非常差,内存消耗很大,一次执行就要消耗190MB,执行时间超过2s。如果是放到WebAPI里面调用,用户会有明显的卡顿感觉;如果面临高并发的情况,很可得会造成服务器资源紧张,返回各种500错误。

优化代码

初筛

按照我们的优化思路,在查看上面的代码后,发现一个严重的问题。

虽然每次LINQ查询返回都是IQueryable类型,但是源码中有多个ToList(),尤其是第一个,它的意思是将Author, Book,User,Role,Publisher等多个数据表的数据全部载入,前面已经说了,Author, Book两张表的数据量很大,必然影响性能。

我们需要删除前面多余的ToList(),只保留最后的即可。请参考附录中的方法GetAuthors_RemoveToList()。

在GetAuthors_RemoveToList()基础上,对照用户的需求,发现查询结果中包含了Role相关的信息和很多Id信息,但是查询结果并不需要这些,因此必须删掉。请参考附录中的方法GetAuthorsOptimized_RemoveColumn()

在GetAuthorsOptimized_RemoveColumn的基础上,我们再加入AsNoTracking方法。请参考附录中的方法GetAuthorsOptimized_AsNoTracking()

我们在Benchmark中,测试上面提到的三个方法,直接结果如下:

在这里插入图片描述

从Benchmark的测试结果上看,删除多余ToList方法和删除多余的栏位,确实带来了性能的大幅提升。

但是增加AsNoTracking,性能提反而下降了一点。这也说明了AsNoTracking并不是适用所有场景。Select投影操作生成的AuthorWeb对像,并不是EF管理的,与DbContext无关,它只是作为前端API的返回值。相当于EF做了没有用的事,所以性能略有下降。

代码进一步调整

初筛阶段完成后,下面对代码进一步整理

下面Take和Order操作可以并入基本的查询中,Take可以帮助我们减少返回值的数量。请见 GetAuthorsOptimized_ChangeOrder()方法。

var orderedAuthors = authors.OrderByDescending(x => x.BooksCount).ToList().Take(2).ToList();

在GetAuthorsOptimized_ChangeOrder基础上,对于dbContext.Authors,Author是一张数据量很大的表,我们需要在其进行联表操作前,先过滤掉不需要的内容,所以我们可以把Where前提,还有就是将排序操作放到投影的Select前面完成。请见 GetAuthorsOptimized_ChangeOrder方法。

上面的两个优化方法的执行结果如下:

在这里插入图片描述
可以看到性略能有提升。

下面我们为了进一步提升性能,可以查看一下生成的SQL代码,看看是否还有优化的空间。

GetAuthorsOptimized_ChangeOrder方法生成的SQL如下:

      SELECT [u].[FirstName], [u].[LastName], [u].[Email], [u].[UserName], [t].[
BooksCount], [t].[Id], [u].[Id], [b].[Name], [b].[Published], [b].[Id], [t].[Age
], [t].[Country]FROM (SELECT TOP(@__p_0) [a].[Id], [a].[Age], [a].[BooksCount], [a].[Country
], [a].[UserId]FROM [Authors] AS [a]WHERE [a].[Country] = N'France' AND [a].[Age] >= 20ORDER BY [a].[BooksCount] DESC) AS [t]INNER JOIN [Users] AS [u] ON [t].[UserId] = [u].[Id]LEFT JOIN [Books] AS [b] ON [t].[Id] = [b].[AuthorId]ORDER BY [t].[BooksCount] DESC, [t].[Id], [u].[Id]

从生成SQL来看,Author表在使用之前过滤掉了相关的内容,但是直接Left Join了[Books]这个大表。我们可以按照前面提到的1900年以前的查询要求,在左联之前先过滤一下,请参考 GetAuthorsOptimized_SelectFilter方法。

该方法执行后,生成的SQL如下:

      SELECT [u].[FirstName], [u].[LastName], [u].[Email], [u].[UserName], [t].[
BooksCount], [t].[Id], [u].[Id], [t0].[Name], [t0].[Published], [t0].[Id], [t].[
Age], [t].[Country]FROM (SELECT TOP(@__p_1) [a].[Id], [a].[Age], [a].[BooksCount], [a].[Country
], [a].[UserId]FROM [Authors] AS [a]WHERE [a].[Country] = N'France' AND [a].[Age] >= 20ORDER BY [a].[BooksCount] DESC) AS [t]INNER JOIN [Users] AS [u] ON [t].[UserId] = [u].[Id]LEFT JOIN (SELECT [b].[Name], [b].[Published], [b].[Id], [b].[AuthorId]FROM [Books] AS [b]WHERE [b].[Published] < @__date_0) AS [t0] ON [t].[Id] = [t0].[AuthorId]ORDER BY [t].[BooksCount] DESC, [t].[Id], [u].[Id]

在左联之前,确实进行了过滤,该方法的性能测试如下:

在这里插入图片描述
在避免Book表直接进行左联后,性能有所提升。

最后一个优化点,是在EF Core 5.0里面提供了带Filter功能的Include方法,也可以用于本案例的优化,但是该特性但是存在一些局限性,具体请参考EF Core中带过滤器参数的Include方法

但是此方法又涉及了将IQueryable转换成IEnumerable的操作,最后要将生成的Author对象全部转换成AuthorWeb对象。代码过于繁琐,而且带来的性能提升也不明显。因此放弃这个点。

dbContext.Authors.AsNoTracking().Include(x => x.Books.Where(b => b.Published < date))......

结论

从这个优化过程来看,其实对性能提升最大的贡献就是删除多余的ToList(),避免全表载入和删除不需要的栏位两项。其它所谓更精细的优化,性能提升有限。

附录

实体类定义

 public class Author{public int Id { get; set; }public int Age { get; set; }public string Country { get; set; }public int BooksCount { get; set; }public string NickName { get; set; }[ForeignKey("UserId")]public User User { get; set; }public int UserId { get; set; }public virtual List<Book> Books { get; set; } = new List<Book>();}public class Book{public int Id { get; set; }public string Name { get; set; }[ForeignKey("AuthorId")]public Author Author { get; set; }public int AuthorId { get; set; }public DateTime Published { get; set; }public string ISBN { get; set; }[ForeignKey("PublisherId")]public Publisher Publisher { get; set; }public int PublisherId { get; set; }}
public class Publisher{public int Id { get; set; }public string Name { get; set; }public DateTime Established { get; set; }}public class User{public int Id { get; set; }public string FirstName { get; set; }public string LastName { get; set; }public string UserName { get; set; }public string Email { get; set; }public virtual List<UserRole> UserRoles { get; set; } = new List<UserRole>();public DateTime Created { get; set; }public bool EmailConfirmed { get; set; }public DateTime LastActivity { get; set; }}public class Role{public int Id { get; set; }public virtual List<UserRole> UserRoles { get; set; } = new List<UserRole>();public string Name { get; set; }}public  class AuthorWeb{public DateTime UserCreated { get; set; }public bool UserEmailConfirmed { get; set; }public string UserFirstName { get; set; }public DateTime UserLastActivity { get; set; }public string UserLastName { get; set; }public string UserEmail { get; set; }public string UserName { get; set; }public int UserId { get; set; }public int AuthorId { get; set; }public int Id { get; set; }public int RoleId { get; set; }public int BooksCount { get; set; }public List<BookWeb> AllBooks { get; set; }public int AuthorAge { get; set; }public string AuthorCountry { get; set; }public string AuthorNickName { get; set; }}public class BookWeb{public int Id { get; set; }public string Name { get; set; }public DateTime Published { get; set; }public int PublishedYear { get; set; }public string PublisherName { get; set; }public string ISBN { get; set; }}

优化方法

[Benchmark]
public  List<AuthorWeb> GetAuthors() {using var dbContext = new AppDbContext();var authors = dbContext.Authors.Include(x => x.User).ThenInclude(x => x.UserRoles).ThenInclude(x => x.Role).Include(x => x.Books).ThenInclude(x => x.Publisher).ToList().Select(x => new AuthorWeb{UserCreated = x.User.Created,UserEmailConfirmed = x.User.EmailConfirmed,UserFirstName = x.User.FirstName,UserLastActivity = x.User.LastActivity,UserLastName = x.User.LastName,UserEmail = x.User.Email,UserName = x.User.UserName,UserId = x.User.Id,RoleId = x.User.UserRoles.FirstOrDefault(y => y.UserId == x.UserId).RoleId,BooksCount = x.BooksCount,AllBooks = x.Books.Select(y => new BookWeb{Id = y.Id,Name = y.Name,Published = y.Published,ISBN = y.ISBN,PublisherName = y.Publisher.Name}).ToList(),AuthorAge = x.Age,AuthorCountry = x.Country,AuthorNickName = x.NickName,Id = x.Id}).ToList().Where(x => x.AuthorCountry == "France" && x.AuthorAge >= 20).ToList();var orderedAuthors = authors.OrderByDescending(x => x.BooksCount).ToList().Take(2).ToList();List<AuthorWeb> finalAuthors = new List<AuthorWeb>();foreach (var author in orderedAuthors){List<BookWeb> books = new List<BookWeb>();var allBooks = author.AllBooks;foreach (var book in allBooks){if (book.Published.Year < 1900){book.PublishedYear = book.Published.Year;books.Add(book);}}author.AllBooks = books;finalAuthors.Add(author);}return finalAuthors;}[Benchmark]public List<AuthorWeb> GetAuthors_RemoveToList(){using var dbContext = new AppDbContext();var authors = dbContext.Authors.Include(x => x.User).ThenInclude(x => x.UserRoles).ThenInclude(x => x.Role).Include(x => x.Books).ThenInclude(x => x.Publisher)//  .ToList().Select(x => new AuthorWeb{UserCreated = x.User.Created,UserEmailConfirmed = x.User.EmailConfirmed,UserFirstName = x.User.FirstName,UserLastActivity = x.User.LastActivity,UserLastName = x.User.LastName,UserEmail = x.User.Email,UserName = x.User.UserName,UserId = x.User.Id,RoleId = x.User.UserRoles.FirstOrDefault(y => y.UserId == x.UserId).RoleId,BooksCount = x.BooksCount,AllBooks = x.Books.Select(y => new BookWeb{Id = y.Id,Name = y.Name,Published = y.Published,ISBN = y.ISBN,PublisherName = y.Publisher.Name}).ToList(),AuthorAge = x.Age,AuthorCountry = x.Country,AuthorNickName = x.NickName,Id = x.Id})// .ToList().Where(x => x.AuthorCountry == "France" && x.AuthorAge >=20).ToList();var orderedAuthors = authors.OrderByDescending(x => x.BooksCount).ToList().Take(2).ToList();List<AuthorWeb> finalAuthors = new List<AuthorWeb>();foreach (var author in orderedAuthors){List<BookWeb> books = new List<BookWeb>();var allBooks = author.AllBooks;foreach (var book in allBooks){if (book.Published.Year < 1900){book.PublishedYear = book.Published.Year;books.Add(book);}}author.AllBooks = books;finalAuthors.Add(author);}return finalAuthors;}[Benchmark]public  List<AuthorWeb> GetAuthorsOptimized_RemoveColumn(){using var dbContext = new AppDbContext();var authors = dbContext.Authors//   .Include(x => x.User)//.ThenInclude(x => x.UserRoles)//   .ThenInclude(x => x.Role)//   .Include(x => x.Books)//     .ThenInclude(x => x.Publisher).Select(x => new AuthorWeb{//   UserCreated = x.User.Created,//  UserEmailConfirmed = x.User.EmailConfirmed,UserFirstName = x.User.FirstName,//   UserLastActivity = x.User.LastActivity,UserLastName = x.User.LastName,UserEmail = x.User.Email,UserName = x.User.UserName,//     UserId = x.User.Id,//     RoleId = x.User.UserRoles.FirstOrDefault(y => y.UserId == x.UserId).RoleId,BooksCount = x.BooksCount,AllBooks = x.Books.Select(y => new BookWeb{//    Id = y.Id,Name = y.Name,Published = y.Published,//       ISBN = y.ISBN,//         PublisherName = y.Publisher.Name}).ToList(),AuthorAge = x.Age,AuthorCountry = x.Country,AuthorNickName = x.NickName,//   Id = x.Id}).Where(x => x.AuthorCountry == "France" && x.AuthorAge >=20).ToList();var orderedAuthors = authors.OrderByDescending(x => x.BooksCount).ToList().Take(2).ToList();List<AuthorWeb> finalAuthors = new List<AuthorWeb>();foreach (var author in orderedAuthors){List<BookWeb> books = new List<BookWeb>();var allBooks = author.AllBooks;foreach (var book in allBooks){if (book.Published.Year < 1900){book.PublishedYear = book.Published.Year;books.Add(book);}}author.AllBooks = books;finalAuthors.Add(author);}return finalAuthors;}[Benchmark]public List<AuthorWeb> GetAuthorsOptimized_AsNoTracking(){using var dbContext = new AppDbContext();var authors = dbContext.Authors.AsNoTracking()// .Include(x => x.User)//   .ThenInclude(x => x.UserRoles)//   .ThenInclude(x => x.Role)//    .Include(x => x.Books)//   .ThenInclude(x => x.Publisher).Select(x => new AuthorWeb{//UserCreated = x.User.Created,//    UserEmailConfirmed = x.User.EmailConfirmed,UserFirstName = x.User.FirstName,// UserLastActivity = x.User.LastActivity,UserLastName = x.User.LastName,UserEmail = x.User.Email,UserName = x.User.UserName,//  UserId = x.User.Id,//RoleId = x.User.UserRoles.FirstOrDefault(y => y.UserId == x.UserId).RoleId,BooksCount = x.BooksCount,AllBooks = x.Books.Select(y => new BookWeb{// Id = y.Id,Name = y.Name,Published = y.Published,//ISBN = y.ISBN,//PublisherName = y.Publisher.Name}).ToList(),AuthorAge = x.Age,AuthorCountry = x.Country,//AuthorNickName = x.NickName,Id = x.Id}).Where(x => x.AuthorCountry == "France" && x.AuthorAge >=20).ToList();var orderedAuthors = authors.OrderByDescending(x => x.BooksCount).ToList().ToList();List<AuthorWeb> finalAuthors = new List<AuthorWeb>();foreach (var author in authors){List<BookWeb> books = new List<BookWeb>();var allBooks = author.AllBooks;foreach (var book in allBooks){if (book.Published.Year < 1900){book.PublishedYear = book.Published.Year;books.Add(book);}}author.AllBooks = books;finalAuthors.Add(author);}return finalAuthors;}[Benchmark]public List<AuthorWeb> GetAuthorsOptimized_Take_Order(){using var dbContext = new AppDbContext();var authors = dbContext.Authors.AsNoTracking().Select(x => new AuthorWeb{UserFirstName = x.User.FirstName,UserLastName = x.User.LastName,UserEmail = x.User.Email,UserName = x.User.UserName,BooksCount = x.BooksCount,AllBooks = x.Books.Select(y => new BookWeb{Name = y.Name,Published = y.Published,}).ToList(),AuthorAge = x.Age,AuthorCountry = x.Country,AuthorNickName = x.NickName,}).Where(x => x.AuthorCountry == "France" && x.AuthorAge >=20).OrderByDescending(x => x.BooksCount).Take(2).ToList();// var orderedAuthors = authors.OrderByDescending(x => x.BooksCount).ToList().ToList();List<AuthorWeb> finalAuthors = new List<AuthorWeb>();foreach (var author in authors){List<BookWeb> books = new List<BookWeb>();var allBooks = author.AllBooks;foreach (var book in allBooks){if (book.Published.Year < 1900){book.PublishedYear = book.Published.Year;books.Add(book);}}author.AllBooks = books;finalAuthors.Add(author);}return finalAuthors;}[Benchmark]public List<AuthorWeb> GetAuthorsOptimized_ChangeOrder(){using var dbContext = new AppDbContext();var authors = dbContext.Authors.AsNoTracking().Where(x => x.Country == "France" && x.Age >=20).OrderByDescending(x => x.BooksCount)// .Include(x => x.User)//   .ThenInclude(x => x.UserRoles)//   .ThenInclude(x => x.Role)//    .Include(x => x.Books)//   .ThenInclude(x => x.Publisher).Select(x => new AuthorWeb{//UserCreated = x.User.Created,//    UserEmailConfirmed = x.User.EmailConfirmed,UserFirstName = x.User.FirstName,// UserLastActivity = x.User.LastActivity,UserLastName = x.User.LastName,UserEmail = x.User.Email,UserName = x.User.UserName,//  UserId = x.User.Id,//RoleId = x.User.UserRoles.FirstOrDefault(y => y.UserId == x.UserId).RoleId,BooksCount = x.BooksCount,AllBooks = x.Books.Select(y => new BookWeb{// Id = y.Id,Name = y.Name,Published = y.Published,//ISBN = y.ISBN,//PublisherName = y.Publisher.Name}).ToList(),AuthorAge = x.Age,AuthorCountry = x.Country,//AuthorNickName = x.NickName,Id = x.Id})                                     .Take(2).ToList();// var orderedAuthors = authors.OrderByDescending(x => x.BooksCount).ToList().ToList();List<AuthorWeb> finalAuthors = new List<AuthorWeb>();foreach (var author in authors){List<BookWeb> books = new List<BookWeb>();var allBooks = author.AllBooks;foreach (var book in allBooks){if (book.Published.Year < 1900){book.PublishedYear = book.Published.Year;books.Add(book);}}author.AllBooks = books;finalAuthors.Add(author);}return finalAuthors;}//  [Benchmark]public List<AuthorWeb> GetAuthorsOptimized_IncludeFilter(){using var dbContext = new AppDbContext();var date = new DateTime(1900, 1, 1);var authors = dbContext.Authors.AsNoTracking().Include(x => x.Books.Where(b => b.Published < date)).Include(x => x.User)// .IncludeFilter(x =>x.Books.Where(b =>b.Published.Year < 1900)).Where(x => x.Country == "France" && x.Age >=20).OrderByDescending(x => x.BooksCount)//   .ThenInclude(x => x.UserRoles)//   .ThenInclude(x => x.Role)//    .Include(x => x.Books)//   .ThenInclude(x => x.Publisher).Take(2).ToList();// var orderedAuthors = authors.OrderByDescending(x => x.BooksCount).ToList().ToList();var authorList = authors.AsEnumerable().Select(x => new AuthorWeb{//UserCreated = x.User.Created,//    UserEmailConfirmed = x.User.EmailConfirmed,UserFirstName = x.User.FirstName,// UserLastActivity = x.User.LastActivity,UserLastName = x.User.LastName,UserEmail = x.User.Email,UserName = x.User.UserName,//  UserId = x.User.Id,//RoleId = x.User.UserRoles.FirstOrDefault(y => y.UserId == x.UserId).RoleId,BooksCount = x.BooksCount,AllBooks = x.Books//    .Where(b => b.Published < date).Select(y => new BookWeb{// Id = y.Id,Name = y.Name,Published = y.Published,//ISBN = y.ISBN,//PublisherName = y.Publisher.Name}).ToList(),AuthorAge = x.Age,AuthorCountry = x.Country,//AuthorNickName = x.NickName,//    Id = x.Id}).ToList();return authorList;}[Benchmark]public List<AuthorWeb> GetAuthorsOptimized_SelectFilter(){using var dbContext = new AppDbContext();var date = new DateTime(1900, 1, 1);var authors = dbContext.Authors.AsNoTracking().Include(x => x.Books.Where(b => b.Published < date)).Where(x => x.Country == "France" && x.Age >=20).OrderByDescending(x => x.BooksCount).Select(x => new AuthorWeb{//UserCreated = x.User.Created,//    UserEmailConfirmed = x.User.EmailConfirmed,UserFirstName = x.User.FirstName,// UserLastActivity = x.User.LastActivity,UserLastName = x.User.LastName,UserEmail = x.User.Email,UserName = x.User.UserName,//  UserId = x.User.Id,//RoleId = x.User.UserRoles.FirstOrDefault(y => y.UserId == x.UserId).RoleId,BooksCount = x.BooksCount,AllBooks = x.Books.Where(b => b.Published < date).Select(y => new BookWeb{// Id = y.Id,Name = y.Name,Published = y.Published,//ISBN = y.ISBN,//PublisherName = y.Publisher.Name}).ToList(),AuthorAge = x.Age,AuthorCountry = x.Country,//AuthorNickName = x.NickName,//    Id = x.Id}).Take(2).ToList();return authors;}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/171095.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

HarmonyOS鸿蒙原生应用开发设计- 流转图标

HarmonyOS设计文档中&#xff0c;为大家提供了独特的流转图标&#xff0c;开发者可以根据需要直接引用。 开发者直接使用官方提供的流转图标内容&#xff0c;既可以符合HarmonyOS原生应用的开发上架运营规范&#xff0c;又可以防止使用别人的图标侵权意外情况等&#xff0c;减…

【Linux】Linux+Nginx部署项目

&#x1f973;&#x1f973;Welcome Huihuis Code World ! !&#x1f973;&#x1f973; 接下来看看由辉辉所写的关于Linux的相关操作吧 目录 &#x1f973;&#x1f973;Welcome Huihuis Code World ! !&#x1f973;&#x1f973; 一.单体项目的部署 0.我们需要将要进行部…

数据结构与算法之矩阵: Leetcode 48. 旋转矩阵 (Typescript版)

旋转图像 https://leetcode.cn/problems/rotate-image/ 描述 给定一个 n n 的二维矩阵 matrix 表示一个图像。请你将图像顺时针旋转 90 度。你必须在 原地 旋转图像&#xff0c;这意味着你需要直接修改输入的二维矩阵。请不要 使用另一个矩阵来旋转图像。 示例 1 输入&…

评比无代码低代码平台时,可以考虑以下几个方面

无代码低代码平台是近年来兴起的一种软件开发工具&#xff0c;它们旨在帮助非技术人员快速创建应用程序&#xff0c;而无需编写大量的代码。这些平台通过提供可视化的界面和预先构建的组件&#xff0c;使用户能够通过拖放和配置的方式来构建应用程序。选择无代码低代码平台时&a…

【Jenkins 安装】

一&#xff1a;安装文件夹准备 在/home/admin 界面下新建三个文件夹&#xff0c;用来安装tomcat、maven 1.打开&#xff0c;/home/admin目录 cd /home/admin 2.新建三个文件夹 mkdir tomcat mkdir maven 二&#xff1a;安装tomcat 1.打开tomcat目录进行tomcat的安装 访问:h…

微信小程序:点击按钮出现右侧弹窗

效果 代码 wxml <!-- 弹窗信息 --> <view class"popup-container" wx:if"{{showPopup}}"><view class"popup-content"><!-- 弹窗内容 --><text>这是一个右侧弹窗</text></view> </view> <…

8.(vue3.x+vite)组件间通信方式之window挂实例

前端技术社区总目录(订阅之前请先查看该博客) 效果预览 父组件代码 <template><div><div>{{message }}</div><Child

mybatis学习笔记,使用mybatis的几种方式

随着springboot的出现&#xff0c;绝大多数开源框架和中间件都可以通过springboot来整合&#xff0c;并且使用起来非常简单&#xff0c;但是&#xff0c;今天要介绍的是mybatis原生的使用方法。并且分享一下在结合官网学习过程中遇到的问题。 目录 准备工作 数据库版本说明 …

在VMware Workstation Pro安装win7

1.下载 地址 2.创建虚拟机 3.选择需要安装的系统镜像 4.选择系统版本 通常情况下选择 Windows 7 Ultimate 旗舰版&#xff0c;点击下一步&#xff0c;若提示产品密钥&#xff0c;则忽略 5.虚拟机命名 虚拟机保存位置保持默认即可&#xff0c;如果有需求可以更换位置 6…

机架式服务器介绍

大家都知道服务器分为机架式服务器、刀片式服务器、塔式服务器三类&#xff0c;今天小编就分别讲一讲这三种服务器&#xff0c;第一篇先来讲一讲机架式服务器的介绍。 机架式服务器定义&#xff1a;机架式服务器是安装在标准机柜中的服务器&#xff0c;一般采用19英寸的标准尺寸…

竞赛选题 深度学习人脸表情识别算法 - opencv python 机器视觉

文章目录 0 前言1 技术介绍1.1 技术概括1.2 目前表情识别实现技术 2 实现效果3 深度学习表情识别实现过程3.1 网络架构3.2 数据3.3 实现流程3.4 部分实现代码 4 最后 0 前言 &#x1f525; 优质竞赛项目系列&#xff0c;今天要分享的是 &#x1f6a9; 深度学习人脸表情识别系…

Mysql数据库 4.SQL语言 DQL数据查询语言 查询

DQL数据查询语言 从数据表中提取满足特定条件的记录 1.单表查询 2.多表查询 查询基础语法 select 关键字后指定要查询到的记录的哪些列 语法&#xff1a;select 列名&#xff08;字段名&#xff09;/某几列/全部列 from 表名 [具体条件]&#xff1b; select colnumName…

MySQL 语句

创建表的完整语法 create table t1(id int,name varchar(43),age int); create table 库名.表名( 字段名1 数据类型 约束条件 约束条件 约束条件 约束条件, 字段名2 数据类型 约束条件 约束条件 约束条件 约束条件...); 1. 字段名和数据类型必须…

如何绘制【逻辑回归】中threshold参数的学习曲线

threshold参数的意义是通过筛选掉低于threshold的参数&#xff0c;来对逻辑回归的特征进行降维。 首先导入相应的模块&#xff1a; from sklearn.linear_model import LogisticRegression as LR from sklearn.datasets import load_breast_cancer from sklearn.model_selecti…

内网穿透的应用-Linux JumpServer堡垒机:安全远程访问解决方案

文章目录 前言1. 安装Jump server2. 本地访问jump server3. 安装 cpolar内网穿透软件4. 配置Jump server公网访问地址5. 公网远程访问Jump server6. 固定Jump server公网地址 前言 JumpServer 是广受欢迎的开源堡垒机&#xff0c;是符合 4A 规范的专业运维安全审计系统。JumpS…

tftp服务的搭建

TFTP服务的搭建 1 先更新一下apt包 sudo apt-get update2 服务器端(虚拟机上)安装 TFTP相关软件 sudo apt-get install xinetd tftp tftpd -y3 创建TFTP共享目录 mkdir tftp_sharetftp_shaer的路径是/home/cwz/tftp_share 3.1 修改共享目录的权限 sudo chmod -R 777 tftp…

某大型车企:加强汽车应用安全防护,开创智能网联汽车新篇章

​某车企是安徽省最大的整车制造企业&#xff0c;致力于为全球消费者带来高品质汽车产品和服务体验&#xff0c;是国内最早突破百万销量的汽车自主品牌。该车企利用数字技术推动供应链网络的新型互动&#xff0c;加快数字化转型&#xff0c;持续进行场景创新、生态创新&#xf…

ARM,汇编指令

一、汇编指令 1、搬移指令 mov r0 ,#3 mov r1,r0 msr cpsr,r0 mrs r0,cpsr 2、条件执行及标志位 cmp moveq movgt 3、机器码 1&#xff09;、立即数合法性 2&#xff09;、立即数不合法 ldr r0,0x12345678 伪指令解决不合法的问题 前4位表示16个数&#xff0c;一个数移动2次。 …

springsecurity学习笔记-未完

目录 前言 一、概念 1.什么是springsecurity 2.对比shiro 二、开始项目 1.建立一个空项目&#xff0c;建立module&#xff0c;引入相关依赖 2.启动项目&#xff0c;访问项目 3.自定义密码 总结 前言 记录一下学习springsecurity的过程 开发环境&#xff1a;IDEA 一、概念 1.…

设计模式—创建型模式之单例模式

设计模式—创建型模式之单例模式 介绍 单例模式说明&#xff1a;一个单一的类&#xff0c;负责创建自己的对象&#xff0c;同时确保系统中只有单个对象被创建。 单例模式特点&#xff1a; 某个类只能有一个实例&#xff1b;&#xff08;构造器私有&#xff09;它必须自行创…